<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>Matrix207&#39;s Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="Matrix207's Blog">
<meta property="og:url" content="http://yoursite.com/page/14/index.html">
<meta property="og:site_name" content="Matrix207's Blog">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Matrix207's Blog">
  
    <link rel="alternate" href="/atom.xml" title="Matrix207&#39;s Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
  

</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Matrix207&#39;s Blog</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="Flux RSS"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Rechercher"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" results="0" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main">
  
    <article id="post-net-snmp" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/04/19/net-snmp/" class="article-date">
  <time datetime="2013-04-18T16:00:00.000Z" itemprop="datePublished">2013-04-19</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/network/">network</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/04/19/net-snmp/">net snmp</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="1-Architecture"><a href="#1-Architecture" class="headerlink" title="1.Architecture"></a>1.Architecture</h2><h4 id="1-1-Agent-Architecture"><a href="#1-1-Agent-Architecture" class="headerlink" title="1.1 Agent Architecture"></a>1.1 Agent Architecture</h4><p>Upon starting, the agent goes through the following steps (in SnmpDaemonMain()):</p>
<ul>
<li>reads command line options</li>
<li>decides whether it’s a master or subagent</li>
<li>calls init_agent()<ul>
<li>initializes the mib-module registration tree</li>
<li>registers its own configuration file tokens and callbacks</li>
<li>initializes the Agent Helpers </li>
</ul>
</li>
<li>initializes all the compiled-in mib modules</li>
<li>initializes the base libnetsnmp library</li>
<li>opens all the required ports to listen on</li>
<li>forks</li>
<li>saves persistent data (it’s likely at least something has changed already)</li>
<li>sends a coldStart trap</li>
<li>invokes receive() to perform the main packet handling </li>
</ul>
<p>Reference: <a href="http://www.net-snmp.org/wiki/index.php/Agent_Architecture" target="_blank" rel="external">Agent_Architecture</a></p>
<h4 id="1-2-snmpget-snmpset-snmpwalk-snmptrap"><a href="#1-2-snmpget-snmpset-snmpwalk-snmptrap" class="headerlink" title="1.2 snmpget snmpset snmpwalk snmptrap"></a>1.2 snmpget snmpset snmpwalk snmptrap</h4><p>Reference: <a href="http://www.net-snmp.org/wiki/index.php/TUT:mib2c_General_Overview" target="_blank" rel="external">mib2c_General_Overview</a></p>
<pre><code>* snmptranslate: learning about the MIB tree.
* snmpget:       retrieving data from a host.
* snmpgetnext:   retrieving unknown indexed data.
* snmpwalk:      retrieving lots of data at once!
* snmptable:     displaying a table.
* snmpset:       peforming write operations.
* snmpbulkget:   communicates with a network entity using SNMP GETBULK request
* snmpbulkwalk:  retrieve a sub-tree of management values using SNMP GETBULK requests.
* snmptrap:      sending traps messages, and acting upon them.
* snmptrapd:     receive and logs SNMP TRAP and INFORM messages.  

for more, use &apos;man&apos; command to see usage.
</code></pre><p>example: </p>
<pre><code>#### snmpwalk
[dennis@localhost ~]$ snmpwalk -v2c -c public 192.168.110.98 .1.3.6.1.4.1.50369
...
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.3.1 = INTEGER: 856398
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.4.1 = INTEGER: 432164
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.5.1 = INTEGER: 424234
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.6.1 = INTEGER: 1
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.7.1 = INTEGER: 3
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.8.1 = STRING: &quot;0:1 0:2 0:3 &quot;
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.9.1 = INTEGER: 3
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.10.1 = INTEGER: 0
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.11.1 = INTEGER: 4
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.12.1 = INTEGER: 0
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.13.1 = INTEGER: 5

#### snmpget
[dennis@localhost ~]$ snmpget -v2c -c public 192.168.110.98 .1.3.6.1.4.1.50369.1.1.2.5.1.3.1
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.3.1 = INTEGER: 856398

[dennis@localhost ~]$ snmpget -v2c -c public 192.168.110.98 .1.3.6.1.4.1.50369.1.1.2.5.1.8.1
SNMPv2-SMI::enterprises.50369.1.1.2.5.1.8.1 = STRING: &quot;0:1 0:2 0:3 &quot;

#### snmpset
[dennis@localhost ~]$ snmpset -v2c -c private 192.168.110.98 .1.3.6.1.4.1.50369.1.1.1.3.1.0 i 2
SNMPv2-SMI::enterprises.50369.1.1.1.3.1.0 = INTEGER: 2

[dennis@localhost ~]$ snmpset -v2c -c private 192.168.110.98 .1.3.6.1.4.1.50369.1.1.1.3.2.0 s &quot;2013-08-16 15:32:40&quot;
SNMPv2-SMI::enterprises.50369.1.1.1.3.2.0 = STRING: &quot;2013-08-16 15:32:40&quot;

#### snmptrap
# use snmptrapd to receive trap message.
# 1.first create file &quot;touch /usr/local/share/snmp/snmptrapd.conf&quot; 
# 2.then add &quot;authcommunity execute,log,net public&quot; to the file to access 
#   receive trap message.
# (use command &apos;snmpconf&apos; to create and config is another choise)
# use root to start snmptrapd 
[root@localhost ~]# snmptrapd -f -Le -F &quot;%02.2h:%02.2j TRAP%w.%q from %b\n %v\n&quot;
NET-SNMP version 5.7.2
14:30 TRAP0.0 from UDP: [192.168.110.39]:52222-&gt;[192.168.50.63]:162
 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1) 0:00:00.01    SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-SMI::enterprises.50369.1.3.0.1    SNMPv2-SMI::enterprises.50369.1.1.2 = INTEGER: 1
15:38 TRAP0.0 from UDP: [172.16.110.39]:35505-&gt;[172.16.50.63]:162
 SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-SMI::enterprises.50369    SNMPv2-SMI::enterprises.50369.1.1.2 = STRING: &quot;string value test&quot;    

root:~# snmptrap -v 2c -c public 192.168.50.63 1 .1.3.6.1.4.1.50369.1.3.0.1 .1.3.6.1.4.1.50369.1.1.2 i 1
root:~# snmptrap -v 2c -c public 192.168.50.63 &quot;abc&quot; .1.3.6.1.4.1.50369 .1.3.6.1.4.1.50369.1.1.2 s &quot;string value test&quot;
</code></pre><h2 id="2-Install"><a href="#2-Install" class="headerlink" title="2. Install"></a>2. Install</h2><h4 id="2-1-Yum"><a href="#2-1-Yum" class="headerlink" title="2.1 Yum"></a>2.1 Yum</h4><p><strong>install snmp</strong><br><code>su -c &#39;yum install net-snmp&#39;</code></p>
<p><strong>install mib2c</strong><br><code>su -c &#39;yum install net-snmp-perl&#39;</code></p>
<p><strong>install utils tools</strong>:snmpwalk, snmpget,…<br><code>su -c &#39;yum install net-snmp-utils&#39;</code></p>
<h2 id="3-Steps"><a href="#3-Steps" class="headerlink" title="3. Steps"></a>3. Steps</h2><h4 id="3-1-net-snmp中如何加自定义的mib库"><a href="#3-1-net-snmp中如何加自定义的mib库" class="headerlink" title="3.1 net-snmp中如何加自定义的mib库"></a>3.1 <a href="http://bbs.csdn.net/topics/300080590" target="_blank" rel="external">net-snmp中如何加自定义的mib库</a></h4><ul>
<li>Write your self-defined mibs</li>
<li>Copy to /usr/local/share/snmp/mibs</li>
<li>用snmptranslate -Ts -m ALL 就可以看到所以OID的输出了，当然也包括你新加的。<br>如果写的mib文件不正确，应该不能输出，你可以找第三方工具来验证你的文件格式是否正确。</li>
<li>编写相关的函数。<ul>
<li>为你的mib新建一个c文件，可以使用mib2c这样的工具来完成。</li>
<li>如果该OID是只读的，那就在该文件里编写一个只读的函数（mib2c应该会生成的）；如果可写，也应该有一个写的函数（相样是生成的）</li>
</ul>
</li>
</ul>
<h4 id="3-2-Self-defined-Mib"><a href="#3-2-Self-defined-Mib" class="headerlink" title="3.2 Self-defined Mib"></a>3.2 Self-defined Mib</h4><p>I don’t find any good tools for generate mibs, what I do is hacking by hand; if<br>you know some good tool, don’t forget to tell me.</p>
<pre><code>--============================================================
-- Dennis Sample Management Information Base (MIB)
--============================================================

DENNIS-MIB DEFINITIONS ::= BEGIN

IMPORTS
    DisplayString,
    PhysAddress,
    MacAddress,
    DateAndTime,
    RowStatus,
    TEXTUAL-CONVENTION
        FROM SNMPv2-TC
    MODULE-IDENTITY,
    OBJECT-TYPE,
    NOTIFICATION-TYPE,
    Integer32,
    IpAddress,
    TimeTicks,
    Unsigned32
        FROM SNMPv2-SMI;

--============================================================
-- MODULE IDENTITY : dennis
--============================================================

dennis MODULE-IDENTITY
    LAST-UPDATED &quot;201308160000Z&quot;
    ORGANIZATION &quot;MIB&quot;
    CONTACT-INFO
        &quot;Shenzhen, China, Earth village, Solar system
         http://matrix207.github.com
         E-mail: dennis.cpp@gmail.com&quot;
    DESCRIPTION
        &quot;Sample MIB Definition  for
        iso(1).org(3).dod(6).internet(1).private(4).enterprises(1).dennis(9913)&quot;
    ::= { 1  3  6  1  4  1  9913 }


--============================================================
-- Definition of the Sample MIB Common Objects
--============================================================

dennisSampleMib OBJECT IDENTIFIER       ::= { dennis 1 }

--============================================================
-- Definition of the Information Group
--============================================================


dennisSystemInformation OBJECT IDENTIFIER  ::= { dennisSampleMib 1 }

--============================================================
-- Definition of the Information Group (Object type: scalar)
--============================================================

dennisSysInfoEntry OBJECT IDENTIFIER  ::= { dennisSystemInformation 1 }

dennisSystemOSVersion OBJECT-TYPE
    SYNTAX  DisplayString (SIZE (64))
    MAX-ACCESS read-only
    STATUS  current
    DESCRIPTION
        &quot;This object show the operator system version.&quot;
    ::= { dennisSysInfoEntry 1 }


dennisSystemOSBit OBJECT-TYPE
    SYNTAX  Integer32
    MAX-ACCESS read-only
    STATUS  current
    DESCRIPTION
        &quot;This object show the operator system bit&quot;
    ::= { dennisSysInfoEntry 2 }


dennisSystemCPU OBJECT-TYPE
    SYNTAX  Integer32
    MAX-ACCESS read-only
    STATUS  current
    DESCRIPTION
        &quot;The speed of processor, unit: MHZ&quot;
    ::= { dennisSysInfoEntry 3 }


dennisSystemMemory OBJECT-TYPE
    SYNTAX  Integer32
    MAX-ACCESS read-only
    STATUS  current
    DESCRIPTION
        &quot;The total number of memory, unit: MB&quot;
    ::= { dennisSysInfoEntry 4 }


dennisSystemDiskSizy OBJECT-TYPE
    SYNTAX     Integer32
    MAX-ACCESS read-only
    STATUS     current
    DESCRIPTION
        &quot;The total size of disks&quot;
    ::= { dennisSysInfoEntry 5 }


--============================================================
-- Definition of the Directory Group Mount on Root (Object type: table)
--============================================================

dennisSubDirOfRootInformationTable    OBJECT-TYPE
    SYNTAX    SEQUENCE OF DennisSubDirOfRootInformationEntry
    MAX-ACCESS    not-accessible
    STATUS    current
    DESCRIPTION
        &quot;A list of expander chassis information.&quot;
    ::= { dennisSampleMib 2 }


dennisSubDirOfRootInformationEntry    OBJECT-TYPE
    SYNTAX    DennisSubDirOfRootInformationEntry
    MAX-ACCESS    not-accessible
    STATUS    current
    DESCRIPTION
        &quot;A expander chassis information entry&quot;
    INDEX    { dennisSubDirOfRootIndex }
    ::= { dennisSubDirOfRootInformationTable 1 }


DennisSubDirOfRootInformationEntry    ::=
    SEQUENCE {
       dennisSubDirOfRootIndex Integer32,
       dennisSubDirOfRootName  DisplayString,
       dennisSubDirOfRootSize  Integer32,           
       dennisSubDirOfRootDate  DisplayString }

dennisSubDirOfRootIndex OBJECT-TYPE
    SYNTAX    Integer32
    MAX-ACCESS    read-only
    STATUS    current
    DESCRIPTION
        &quot;The index.&quot;
    ::= { dennisSubDirOfRootInformationEntry 1 }

dennisSubDirOfRootName OBJECT-TYPE
    SYNTAX    DisplayString (SIZE (64)) 
    MAX-ACCESS    read-only
    STATUS    current
    DESCRIPTION
        &quot;The type of expander chassis.&quot;
    ::= { dennisSubDirOfRootInformationEntry 2 }

dennisSubDirOfRootSize OBJECT-TYPE
    SYNTAX    Integer32
    MAX-ACCESS    read-only
    STATUS    current
    DESCRIPTION
        &quot;The expander chassis manufacturer&apos;s id.&quot;
    ::= { dennisSubDirOfRootInformationEntry 3 }

dennisSubDirOfRootDate OBJECT-TYPE
    SYNTAX    DisplayString
    MAX-ACCESS    read-only
    STATUS    current
    DESCRIPTION
        &quot;The total number of physical slots for physical
        disk on the chassis.&quot;
    ::= { dennisSubDirOfRootInformationEntry 4 }


--============================================================
-- Definition of access object (Object type: scalar)
--============================================================
dennisAccessObject OBJECT IDENTIFIER  ::= { dennisSampleMib 3 }

dennisShutdownType OBJECT-TYPE
    SYNTAX  Integer32
    MAX-ACCESS read-write
    STATUS  current
    DESCRIPTION
        &quot;Use for shudown operator system, 1:shutdown 2:reboot&quot;
        ::= { dennisAccessObject 1 }


--============================================================
-- End Definition
--============================================================
END
</code></pre><h4 id="3-3-Check-mib"><a href="#3-3-Check-mib" class="headerlink" title="3.3 Check mib"></a>3.3 Check mib</h4><pre><code>[root@localhost mib]# snmptranslate -Tp -m DENNIS-MIB
+--iso(1)
   |
   +--anonymous#0(3)
      |
      +--anonymous#1(6)
         |
         +--anonymous#2(1)
            |
            +--anonymous#3(4)
               |
               +--anonymous#4(1)
                  |
                  +--dennis(9913)
                     |
                     +--dennisSampleMib(1)
                        |
                        +--dennisSystemInformation(1)
                        |  |
                        |  +--dennisSysInfoEntry(1)
                        |     |
                        |     +-- -R-- String    dennisSystemOSVersion(1)
                        |     |        Textual Convention: DisplayString
                        |     |        Size: 64
                        |     +-- -R-- Integer32 dennisSystemOSBit(2)
                        |     +-- -R-- Integer32 dennisSystemCPU(3)
                        |     +-- -R-- Integer32 dennisSystemMemory(4)
                        |     +-- -R-- Integer32 dennisSystemDiskSizy(5)
                        |
                        +--dennisSubDirOfRootInformationTable(2)
                        |  |
                        |  +--dennisSubDirOfRootInformationEntry(1)
                        |     |  Index: dennisSubDirOfRootIndex
                        |     |
                        |     +-- -R-- Integer32 dennisSubDirOfRootIndex(1)
                        |     +-- -R-- String    dennisSubDirOfRootName(2)
                        |     |        Textual Convention: DisplayString
                        |     |        Size: 64
                        |     +-- -R-- Integer32 dennisSubDirOfRootSize(3)
                        |     +-- -R-- String    dennisSubDirOfRootDate(4)
                        |              Textual Convention: DisplayString
                        |              Size: 0..255
                        |
                        +--dennisAccessObject(3)
                           |
                           +-- -RW- Integer32 dennisShutdownType(1)
</code></pre><h2 id="4-Use-mib2c"><a href="#4-Use-mib2c" class="headerlink" title="4. Use mib2c"></a>4. Use mib2c</h2><h4 id="4-1-mib-object"><a href="#4-1-mib-object" class="headerlink" title="4.1 mib object"></a>4.1 mib object</h4><p>scalar: int,  string,  time and so on.<br>table : table has row and column, like table in database.  </p>
<h4 id="4-2-use-mib2c-to-create-source-file"><a href="#4-2-use-mib2c-to-create-source-file" class="headerlink" title="4.2 use mib2c to create source file"></a>4.2 use mib2c to create source file</h4><p><strong>append string “DENNIS-MIB” to config file: snmpd.conf</strong><br><code>su -c &#39;vim /etc/snmp/snmpd.conf&#39;</code>  </p>
<p><strong>copy mib file to mibs directory(depend on which directory mib2c installed)</strong><br><code>su -c &#39;cp DENNIS-MIB.txt /usr/local/share/snmp/mibs/&#39;</code>  </p>
<p><strong>generate c source file by mib2c</strong><br><code>mib2c -c mib2c.scalar.conf DENNIS-MIB::dennis</code>  for scalar object<br><code>mib2c -c mib2c.old-api.conf DENNIS-MIB::dennis</code> for scalar  object<br><code>mib2c -c mib2c.iterate.conf DENNIS-MIB::dennis</code> for table  object (choise 2)<br><code>mib2c -c mib2c.notify.conf DENNIS-MIB::dennis</code> for trapping message<br>if failed to translate, check the mibs directory again, or look the output message.</p>
<p>more configure files, look as below:  </p>
<pre><code>[dennis@localhost net-snmp-5.4.2]$ ls /usr/local/share/snmp/*.conf
/usr/local/share/snmp/mib2c.access_functions.conf    
/usr/local/share/snmp/mib2c.int_watch.conf
/usr/local/share/snmp/mib2c.array-user.conf          
/usr/local/share/snmp/mib2c.iterate_access.conf
/usr/local/share/snmp/mib2c.check_values.conf        
/usr/local/share/snmp/mib2c.iterate.conf
/usr/local/share/snmp/mib2c.check_values_local.conf  
/usr/local/share/snmp/mib2c.mfd.conf
/usr/local/share/snmp/mib2c.column_defines.conf      
/usr/local/share/snmp/mib2c.notify.conf
/usr/local/share/snmp/mib2c.column_enums.conf        
/usr/local/share/snmp/mib2c.old-api.conf
/usr/local/share/snmp/mib2c.column_storage.conf      
/usr/local/share/snmp/mib2c.perl.conf
/usr/local/share/snmp/mib2c.conf                     
/usr/local/share/snmp/mib2c.raw-table.conf
/usr/local/share/snmp/mib2c.container.conf           
/usr/local/share/snmp/mib2c.scalar.conf
/usr/local/share/snmp/mib2c.create-dataset.conf      
/usr/local/share/snmp/mib2c.table_data.conf
/usr/local/share/snmp/mib2c.genhtml.conf             
/usr/local/share/snmp/snmptrapd.conf
</code></pre><h2 id="5-Add-self-defined-mib-library"><a href="#5-Add-self-defined-mib-library" class="headerlink" title="5. Add self-defined mib library"></a>5. Add self-defined mib library</h2><h4 id="5-1-steps"><a href="#5-1-steps" class="headerlink" title="5.1 steps:"></a>5.1 steps:</h4><p>使用net-snmp扩展私有MIB的大致方法<br>参考： <a href="http://net-snmp.sourceforge.net/tutorial/tutorial-5/toolkit/mib_module/index.html" target="_blank" rel="external">net-snmp tutorial</a></p>
<p>step 1. 首先需要使用net-snmp的相关API编写MIB相关C代码，</p>
<pre><code>1. MFD/mib2c：这是一种通过net-snmp提供的mib2c程序自动生成相关代码的方式
2. A simple scalar attached to a variable：适合于简单变量类型的object
3. A simple scalar with the value returned from code：适用于任何变量类型的object
</code></pre><p>step 2. 然后将刚写的MIB C code编译进net-snmp，有几种方法：</p>
<pre><code>1. compile it into master agent：
  1）将刚编写的码加入net-snmp的src目录，
  2）通过configure的option指示make编译该mib，
     如./configure --with-mib-modules=&quot;myobject&quot; 
  3）make
  4）make install
  这样，你的MIB就已经被内置如snmp服务程序中了，MIB的生效也就理所当然

2. compile your code into a “subagent”：
  这种方式可以将subagent通过agentx协议与master agent通信，
  参考： http://net-snmp.sourceforge.net/tutorial/tutorial-5/toolkit/demon/index.html
  这种情况subagent最终是一个独立的application，包含两种生成方式，
  1).是通过net-snmp-config工具生成；
  2).是自己编写程序控制调用；
  后者更为灵活，subagent功能可以被集成在其它application中。

3. compile your code into pluggable shared object and tell the snmpd agent to load it
  这种方式最后生成一个.so的共享库，用户启动snmpd服务时可以通过指定参数的方式
  加载该共享库以扩展MIB，
  参考： http://net-snmp.sourceforge.net/tutorial/tutorial-5/toolkit/dlmod/index.html 
</code></pre><h4 id="5-2-compile-net-snmp-by-shell-script"><a href="#5-2-compile-net-snmp-by-shell-script" class="headerlink" title="5.2 compile net-snmp by shell script"></a>5.2 compile net-snmp by shell script</h4><pre><code>cd /home/dennis/net-snmp-5.4.2/
cp -f /home/dennis/dennis.{h,c} ./agent/mibgroup
./configure --prefix=/usr --with-mib-modules=&quot;dennis&quot;
make clean
make
make install
</code></pre><h4 id="5-3-update-mib"><a href="#5-3-update-mib" class="headerlink" title="5.3 update mib"></a>5.3 update mib</h4><pre><code>copy &quot;net-snmp-5.4.2/agent/.libs/libnetsnmpmibs.so&quot; to &quot;/usr/lib/&quot;,  
64bit system is to &quot;/usr/lib64/&quot;
</code></pre><h4 id="5-4-check-the-so-had-have-the-interfaces-which-you-implement"><a href="#5-4-check-the-so-had-have-the-interfaces-which-you-implement" class="headerlink" title="5.4 check the so had have the interfaces which you implement"></a>5.4 check the so had have the interfaces which you implement</h4><pre><code>[root@ ~]# which snmpd
/usr/sbin/snmpd
[root@ ~]# ldd /usr/sbin/snmpd | grep libnetsnmpmib
    libnetsnmpmibs.so.15 =&gt; /usr/lib64/libnetsnmpmibs.so.15 (0x0000003655600000)
[root@ ~]# nm /usr/lib64/libnetsnmpmibs.so.15 | grep &quot;YOUR_INTERFACE_KEY&quot;
</code></pre><h4 id="5-5-check-config-file"><a href="#5-5-check-config-file" class="headerlink" title="5.5 check config file"></a>5.5 check config file</h4><pre><code>check the file /etc/snmp/snmpd.conf, append `rwcommunity private` to it to 
make access authority for `snmpset`.
</code></pre><h4 id="5-6-restart-snmp"><a href="#5-6-restart-snmp" class="headerlink" title="5.6 restart snmp"></a>5.6 restart snmp</h4><pre><code>/usr/sbin/snmpd -c /etc/snmp/snmpd.conf -Le
</code></pre><h2 id="6-Improve-speed"><a href="#6-Improve-speed" class="headerlink" title="6. Improve speed"></a>6. Improve speed</h2><p>When snmp agent receive lots of request, and if do some I/O operation of each<br>request, that will show a low performance.<br>One not-bad solution is use a thread do the I/O job, and store the information<br>to memory (using global variable, array, structure …), then fill info and<br>return to client when get the request.</p>
<h4 id="6-1-add-thread-function-to-mib-file"><a href="#6-1-add-thread-function-to-mib-file" class="headerlink" title="6.1 add thread function to mib file"></a>6.1 add thread function to mib file</h4><p>Add include <code>#include &lt;pthread.h&gt;</code> to the mib file<br>Write thread function like this: <code>void *update_all_info (void *parm);</code></p>
<h4 id="6-2-modify-Makefile"><a href="#6-2-modify-Makefile" class="headerlink" title="6.2 modify Makefile"></a>6.2 modify Makefile</h4><p>Add link library(<code>-lpthread</code>) to agent/Makefile (line:199):<br><code>LOCAL_LIBS    = -L../snmplib/.libs -L../snmplib -L./.libs -L./helpers/.libs -L./helpers -lpthread</code></p>
<h2 id="7-Reference"><a href="#7-Reference" class="headerlink" title="7. Reference"></a>7. Reference</h2><h4 id="7-1-network-link"><a href="#7-1-network-link" class="headerlink" title="7.1 network link"></a>7.1 network link</h4><ul>
<li><a href="http://imxie.net/2011/07/use_pass_for_snmp_get_and_set.htm" target="_blank" rel="external">net-snmp之利用pass做snmpget和snmpset</a></li>
<li><a href="http://www.linuxfly.org/post/556/" target="_blank" rel="external">自定义SNMP Agent</a></li>
<li><a href="http://bbs.csdn.net/topics/300080590" target="_blank" rel="external">net-snmp中如何加自定义的mib</a></li>
<li><a href="http://blog.csdn.net/linyt/article/details/2842244" target="_blank" rel="external">Extending the UCD-SNMP(net-snmp)agent</a></li>
<li><a href="http://www.net-snmp.org/wiki/index.php/Tutorials" target="_blank" rel="external">Tutorial</a></li>
<li><a href="http://www.net-snmp.org/wiki/index.php/TUT:Writing_a_MIB_Module" target="_blank" rel="external">Writing a MIB Module</a></li>
<li><a href="http://net-snmp.sourceforge.net/tutorial/tutorial-5/toolkit/mib_module/index.html" target="_blank" rel="external">Writing a net-snmp MIB Modul</a></li>
<li><a href="http://blog.csdn.net/bearfig/article/details/2080421" target="_blank" rel="external">在net-snmp agent中扩展自己的mib</a></li>
<li><a href="http://bibu.bokee.com/inc/net_snmp_doc.htm" target="_blank" rel="external">用NET-SNMP软件包开发简单客户端代理★★★★</a></li>
<li><a href="http://bibu.bokee.com/inc/net_snmp_doc.htm#_Toc116812027" target="_blank" rel="external">利用NET-SNMP开发代理(原创</a></li>
<li><a href="http://www.tonylin.idv.tw/dokuwiki/doku.php/snmp:snmp:mibhelloworld" target="_blank" rel="external">第一次寫MIB就上手★★★★</a></li>
<li><a href="http://blog.csdn.net/dumeifang/article/details/4201860" target="_blank" rel="external">FreeBSD snmptrapd.conf配置详解</a></li>
<li><a href="http://velep.com/archives/585.html" target="_blank" rel="external">snmptrap、snmpinform和snmptrapd的详细介绍及其用法</a></li>
<li><a href="http://www.net-snmp.org/wiki/index.php/TUT:Writing_a_Subagent" target="_blank" rel="external">Writing a subagent</a></li>
<li><a href="http://blog.csdn.net/BeyondHaven/article/details/10575601" target="_blank" rel="external">windows下使用net-snmp实现agent扩展 一</a></li>
<li><a href="http://wenku.baidu.com/view/4da5e14df7ec4afe04a1df66.html?from_page=view&amp;from_mod=download###" target="_blank" rel="external">net-snmp在windows上的配置开发及详细的代码流程</a></li>
<li><a href="http://wendang.baidu.com/view/83ee071cfc4ffe473368ab8c.html" target="_blank" rel="external">Windows下使用net-snmp所遇问题及解决</a></li>
<li><a href="http://blog.csdn.net/jxzxm1_2/article/details/2948522" target="_blank" rel="external">VS2005下编译、安装Net-snmp 5.4.1.2手记</a></li>
<li><a href="http://hi.baidu.com/lieyu063/item/e00625c245ee2544a9ba94a0" target="_blank" rel="external">Net-SNMP的第一个agent实现</a></li>
<li><a href="http://blog.csdn.net/sstower/article/details/4791844" target="_blank" rel="external">net-snmp中自定义snmp table的实现</a></li>
<li><a href="http://blog.sina.com.cn/s/blog_8f3de3250100xhao.html" target="_blank" rel="external">net-snmp代理开发——自定义table实现</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/04/19/net-snmp/" data-id="ciqqpe1j6004hnmpvwv9ny7wn" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/network/">network</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-get-mac-with-netbios" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/04/10/get-mac-with-netbios/" class="article-date">
  <time datetime="2013-04-09T16:00:00.000Z" itemprop="datePublished">2013-04-10</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/network/">network</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/04/10/get-mac-with-netbios/">get mac with NetBIOS</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Find-port-139-open-machine"><a href="#Find-port-139-open-machine" class="headerlink" title="Find port 139 open machine:"></a>Find port 139 open machine:</h3><pre><code>[root@localhost netbios]# nmap -p139 192.168.50.22

Starting Nmap 6.25 ( http://nmap.org ) at 2013-04-10 20:49 CST
Nmap scan report for 192.168.50.22
Host is up (0.00023s latency).
PORT    STATE SERVICE
139/tcp open  netbios-ssn
MAC Address: 00:**:09:**:3a:** (Dell)

Nmap done: 1 IP address (1 host up) scanned in 0.12 seconds
</code></pre><h3 id="Search-all"><a href="#Search-all" class="headerlink" title="Search all:"></a>Search all:</h3><pre><code>Linux shell command : 
    nmap -p139 192.168.50.1/24 | sed &apos;/./{H;$!d};x;/open/!d&apos; | grep &apos;scan&apos; | awk &apos;{print $NF}&apos;
or
    nmap -p139 192.168.50.1/24 | grep -B 3 &apos;open&apos; | grep &apos;scan&apos; | awk &apos;{print $NF}&apos;
or 
    nmap -p139 192.168.50.1/24 | tac | sed -n &apos;/open/,+3p&apos; | tac | grep &apos;scan&apos; | awk &apos;{print $NF}&apos;    

[root@localhost netbios]# time nmap -p139 192.168.50.1/24 | grep -B 3 &apos;open&apos; | grep &apos;scan&apos; | awk &apos;{print $NF}&apos;
192.168.50.16
192.168.50.22
192.168.50.26
192.168.50.28
192.168.50.29
192.168.50.36
192.168.50.37
192.168.50.39
...
192.168.50.238

real    0m4.451s
user    0m0.067s
sys    0m0.024s
</code></pre><h3 id="scan-all"><a href="#scan-all" class="headerlink" title="scan all:"></a>scan all:</h3><pre><code>[root@localhost netbios]# nmap -p139 192.168.50.1/24 | grep -B 3 &apos;open&apos; | grep &apos;scan&apos; | awk &apos;{print $NF}&apos; | xargs -n1 ./netbios
 192.168.50.16 : 00-**-19-**-46-**
 192.168.50.22 : 00-**-09-**-3a-**
 192.168.50.26 : b8-**-6f-**-06-**
 192.168.50.28 : 00-**-ae-**-e6-**
 192.168.50.29 : 00-**-c9-**-6d-**
 192.168.50.35 : 00-**-19-**-59-**
 192.168.50.36 : 00-**-ae-**-ee-**
 192.168.50.37 : 00-**-c9-**-8c-**
 192.168.50.39 : 00-**-9b-**-b9-**
...
192.168.50.238 : b8-**-6f-**-28-**
</code></pre><h3 id="netbios-c-source-code"><a href="#netbios-c-source-code" class="headerlink" title="netbios.c source code:"></a>netbios.c source code:</h3><pre><code>// netbios.c
// Get mac address with NetBIOS protocol
// compile with gcc on linux: gcc -o netbios netbios.c
// Create by Dennis
// 2013-04-10
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;unistd.h&gt;
#include &lt;string.h&gt;
#include &lt;sys/socket.h&gt;
#include &lt;arpa/inet.h&gt;
#include &lt;netinet/in.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;netdb.h&gt;
#include &lt;sys/ioctl.h&gt;
#include &lt;net/if.h&gt;

#define NETBIOS_PORT 137

unsigned char bs[50]={ 
    0x0,0x00,0x0,0x10,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x20,0x43,0x4b,0x41,0x41, 
    0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41, 
    0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x0,0x0, 
    0x21,0x0,0x1
};

// 通过NbtStat获取计算机名字信息的结构体  
struct names  
{  
    unsigned char nb_name[16];  // 表示接收到的名字  
    unsigned short name_flags;  // 标识名字的含义  
}; 

void print_buf(unsigned char* buf, int len)
{
    int i = 0;
    for (i=0; i&lt;len; i++)
    {
        if (i%8==0) printf(&quot;\n%04d: &quot;, i);
        printf(&quot;0x%02x &quot;, buf[i]);
    }
    printf(&quot;\n&quot;);
}

void parse_netbios(char* buf, int len)
{
    //print_buf(buf, len);
    char* respuesta = buf;

    // 定义名字数组  
    struct names Names[20*sizeof(struct names)]; 

    int count = 0;

    // 将count定位到名字表中名字的数量。在NetBIOS回应包中，前面56位是网络适配器的状态信息  
    memcpy(&amp;count, respuesta+56, 1);  
    if(count &gt; 20){      // 最多有20个名字，超出则错误  
        return;  
    }  

    // 将名字表内在复制到Names数组中  
    memcpy(Names,(respuesta+57), count*sizeof(struct names));  

    // 将空格字符替换成空  
    unsigned int i,j;
    for(i = 0; i &lt; count;i++) {  
        for(j = 0;j &lt; 15;j++){  
            if(Names[i].nb_name[j] == 0x20)  
                Names[i].nb_name[j]=0;  
        }  
    }

#if 0
    for(i=0;i&lt;count;i++){  
        // 如果最后一位是0x00，则表示当前名字表项为保存计算机名或者工作组  
        if(Names[i].nb_name[15] == 0x00){  
            char buffers[17] = {0};  
            memcpy(buffers, Names[i].nb_name, 16);  
            // 使用name_flags字段来区分当前名字是计算机名还是工作组  
            if((Names[i].name_flags &amp; 128) == 0) {  
                printf(&quot; name: %s\n&quot;, buffers);
            }  
            else{  
                printf(&quot;group: %s\n&quot;, buffers);
            }  
        }  
    }  
#endif

    unsigned char mac[6];
    // 名字表后面是MAC地址  
    memcpy(mac,(respuesta+57+count*sizeof(struct names)),6);  
    printf(&quot;: %02x-%02x-%02x-%02x-%02x-%02x\n&quot;, 
        mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
}

int main(int argc,char*argv[]) {
    int ret=-1;
    int sock=-1;
    //int so_broadcast=1;
    struct sockaddr_in server_addr;
    struct sockaddr_in from_addr;
    int from_len=sizeof(from_addr);
    int count=-1;
    fd_set readfd;

    struct timeval timeout;
    timeout.tv_sec=2;
    timeout.tv_usec=0;

    sock=socket(AF_INET,SOCK_DGRAM,0);
    if (sock&lt;0) {
        printf(&quot;HandleIPFound:sock init error\n&quot;);
        return 1;
    }

    server_addr.sin_family=AF_INET;
    server_addr.sin_port=htons(NETBIOS_PORT);
    //server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
    if (argc &gt; 1)
        server_addr.sin_addr.s_addr = inet_addr(argv[1]);
    else
        server_addr.sin_addr.s_addr = inet_addr(&quot;192.168.50.39&quot;);

    //ret = setsockopt(sock,SOL_SOCKET,SO_BROADCAST,&amp;so_broadcast,sizeof(so_broadcast));

    char recvbuf[1024] = {0};
    int times=10;
    int i=0;
    for (i=0; i&lt;times; i++) {
        timeout.tv_sec=2;
        timeout.tv_usec=0;
        //printf(&quot;==&gt; IP :%s Port:%d\n&quot;,inet_ntoa(server_addr.sin_addr), ntohs(server_addr.sin_port));
        ret = sendto(sock,&amp;bs,sizeof(bs),0,(struct sockaddr*)&amp;server_addr,sizeof(server_addr));
        if (ret==-1) {
            printf(&quot;Failed to do sendto\n&quot;);
            continue;
        }

        FD_ZERO(&amp;readfd);
        FD_SET(sock,&amp;readfd);

        ret = select(sock+1,&amp;readfd,NULL,NULL,&amp;timeout);
        switch (ret) {
            case -1:
                break;
            case 0:
                printf(&quot;%s timeout\n&quot;, inet_ntoa(server_addr.sin_addr));
                return 0;
                break;
            default:
                if(FD_ISSET(sock,&amp;readfd)) {
                    memset(recvbuf, 0, sizeof(recvbuf));
                    count=recvfrom(sock,recvbuf,sizeof(recvbuf),0,(struct sockaddr*)&amp;from_addr,&amp;from_len);
                    printf(&quot;%16s &quot;, inet_ntoa(from_addr.sin_addr));
                    parse_netbios(recvbuf, count);
                    return 1;  
                }
                break;
        }
    }

    return 0;
}
</code></pre><h4 id="Reference"><a href="#Reference" class="headerlink" title="Reference:"></a>Reference:</h4><ul>
<li><a href="http://blog.csdn.net/neicole/article/details/7587414" target="_blank" rel="external">NetBIOS网络编程</a></li>
<li><a href="http://www.2cto.com/kf/201209/155950.html" target="_blank" rel="external">netbios协议探测主机信息</a></li>
<li><a href="http://blog.csdn.net/aspirationflow/article/details/7694274" target="_blank" rel="external">Nmap扫描原理与用法</a></li>
<li><a href="http://tools.ietf.org/html/rfc1002" target="_blank" rel="external">NetBIOS Working Group</a></li>
<li><a href="http://en.wikipedia.org/wiki/NetBIOS" target="_blank" rel="external">NetBIOS WikiPedia</a></li>
<li><a href="http://tech.ddvip.com/2009-06/1244885786123662_2.html" target="_blank" rel="external">精解局域网访问及共享</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/04/10/get-mac-with-netbios/" data-id="ciqqpe1iy004bnmpv97005hqg" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/network/">network</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-find-alive-hosts" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/04/09/find-alive-hosts/" class="article-date">
  <time datetime="2013-04-08T16:00:00.000Z" itemprop="datePublished">2013-04-09</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/network/">network</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/04/09/find-alive-hosts/">Find alive hosts</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>This command can find alive hosts on linux:<br><code>nmap -v -sn 192.168.1.1/24 | grep &#39;Nmap scan&#39; | grep -v &#39;host down&#39;</code></p>
<p>Reference:  </p>
<ul>
<li><a href="http://blog.csdn.net/aspirationflow/article/details/7694274" target="_blank" rel="external">Nmap扫描原理与用法</a></li>
<li><a href="http://blog.sina.com.cn/s/blog_644eb9350100p3yv.html" target="_blank" rel="external">通过ARP探测局域网活动主机</a></li>
<li><a href="http://www.2cto.com/kf/201011/78750.html" target="_blank" rel="external">编写ARP扫描器探测局域网活动主机</a></li>
<li><a href="http://bbs.csdn.net/topics/350022203" target="_blank" rel="external">如何获取局域网内其他主机的ip地址和mac地址</a></li>
<li><a href="http://download.csdn.net/detail/joeycc/4945784" target="_blank" rel="external">icmp探测活动主机</a></li>
<li><a href="http://download.csdn.net/detail/pilipenhuolong/3118860" target="_blank" rel="external">利用ICMP数据包探测网络中的活动主机 VC++</a></li>
<li><a href="http://www.xfocus.net/articles/200103/77.html" target="_blank" rel="external">使用ICMP协议来进行主机探测</a></li>
<li><a href="http://blog.csdn.net/yiyefangzhou24/article/details/6819874" target="_blank" rel="external">一个简单扫描器的实现 </a></li>
</ul>
<p>##sample code  </p>
<h3 id="Find-alive-hosts-with-ARP-protocol"><a href="#Find-alive-hosts-with-ARP-protocol" class="headerlink" title="Find alive hosts with ARP protocol"></a>Find alive hosts with ARP protocol</h3><pre><code>// Find alive hosts with ARP protocol
// Win32 console project, compile with VS2005
// Create by Dennis
// 2013-04-09

// Reference:
// http://msdn.microsoft.com/en-us/library/aa366358(VS.85).aspx

#include &lt;winsock2.h&gt;
#include &lt;iphlpapi.h&gt;
#include &lt;process.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

#pragma comment(lib, &quot;iphlpapi.lib&quot;)
#pragma comment(lib, &quot;ws2_32.lib&quot;)

CRITICAL_SECTION  cs;

unsigned long netIp = 0;

// Get host IP
// Reference: http://blog.csdn.net/happycock/article/details/491424
// If your machine have more than one network adapter, you should
// fix this function.
void GetHostIP(char* ip, int size1, char* mask, int size2)
{
    ULONG len = 0; 
    GetAdaptersInfo(NULL, &amp;len);
    PIP_ADAPTER_INFO p = static_cast&lt;PIP_ADAPTER_INFO&gt;(malloc(len));
    GetAdaptersInfo(p, &amp;len);
    for (PIP_ADAPTER_INFO q = p; q != NULL; q = q-&gt;Next)
    {
        if (ip) strncpy(ip, q-&gt;IpAddressList.IpAddress.String, size1);
        if (mask) strncpy(mask, q-&gt;IpAddressList.IpMask.String, size2);
        break;
    }

    free(p);
}

unsigned int __stdcall ArpThread(LPVOID lParam)
{
    ULONG MacAddr[2];       /* for 6-byte hardware addresses */
    ULONG PhysAddrLen = 6;  /* default to length of six bytes */

#if 1
    EnterCriticalSection(&amp;cs);
    //converts to TCP/IP network byte order (which is big-endian) 
    unsigned long dstIP=htonl(++netIp);
    LeaveCriticalSection(&amp;cs);
#else
    // Reference: http://blog.csdn.net/morewindows/article/details/7429155
    //netIp++;  
    InterlockedIncrement((LPLONG)&amp;netIp);
    unsigned long dstIP=htonl(netIp);
#endif

    if (NO_ERROR == SendARP(dstIP, 0,&amp;(MacAddr[0]),&amp;PhysAddrLen)) {
        EnterCriticalSection(&amp;cs);
        BYTE* bPhysAddr = (BYTE *) &amp; MacAddr;
        if (PhysAddrLen) {
            struct in_addr addr1;
            memcpy(&amp;addr1, &amp;dstIP, 4);
            printf(&quot;%16s : &quot;, inet_ntoa(addr1));
            for (int i = 0; i &lt; (int) PhysAddrLen; i++) {
                if (i == (PhysAddrLen - 1))
                    printf(&quot;%.2X\n&quot;, (int) bPhysAddr[i]);
                else
                    printf(&quot;%.2X-&quot;, (int) bPhysAddr[i]);
            }
        } else
            printf(&quot;Warning: SendArp completed successfully, but returned length=0\n&quot;);
        LeaveCriticalSection(&amp;cs);
    }

    return 0;
}

int main(int argc, char **argv)
{
    IPAddr SrcIp = 0;

    char strSrcIP[16] = {0};
    char strSrcMask[16] = {0};
    // Get Host IP and Mask
    GetHostIP(strSrcIP, sizeof(strSrcIP), strSrcMask, sizeof(strSrcMask));

    InitializeCriticalSection(&amp;cs);

    SrcIp = inet_addr(strSrcIP);
    unsigned long findMask=inet_addr(strSrcMask);
    int netsize = ~ntohl(findMask);
    netIp = ntohl(SrcIp &amp; findMask); 

#if 0
    unsigned long dstIp;
    struct in_addr addr1;
    HANDLE hThr[63] = {0};
    for (int i=1; i&lt;64; i++)
    {
        //converts to TCP/IP network byte order (which is big-endian) 
         dstIp=htonl(netIp+i);

         hThr[i-1] = (HANDLE)_beginthreadex(NULL, 0, ArpThread, &amp;dstIp, 0, NULL);
    }

    WaitForMultipleObjects(63,&amp;(hThr[0]),TRUE,INFINITE);
#else
    HANDLE *phThread = (HANDLE*)malloc(netsize*sizeof(HANDLE));
    for (int i=1; i&lt;netsize; i++)
    {
        // _beginthreadex if more effect than CreateThread
        // you can google it for more information
        phThread[i-1] = (HANDLE)_beginthreadex(NULL, 0, ArpThread, 0, 0, NULL);
    }

    // There is a limit count for function WaitForMultipleObjects
    int netcount = netsize-1;
    int waitcount = 0;
    for (int i=0; i&lt;netcount;)
    {
        waitcount = MAXIMUM_WAIT_OBJECTS;
        if (netcount-i&lt;MAXIMUM_WAIT_OBJECTS)
            waitcount = netcount-i;
        WaitForMultipleObjects(waitcount,&amp;(phThread[i]),TRUE,INFINITE);
        i += waitcount;
    }

    free(phThread);

#endif

    DeleteCriticalSection(&amp;cs);

    //system(&quot;pause&quot;);
    return 0;
}
</code></pre><p><strong>output as below:(For security reasons, replace some of the characters as asterisks)</strong>  </p>
<pre><code>  192.168.50.1 : **-**-E2-**-C7-**
  192.168.50.2 : **-**-4C-**-00-**
 192.168.50.16 : **-**-19-**-46-**
 192.168.50.22 : **-**-09-**-3A-**
 192.168.50.28 : **-**-AE-**-E6-**
 ...
192.168.50.129 : **-**-9B-**-19-**
192.168.50.238 : **-**-6F-**-28-**
Press any key to continue. . .
</code></pre><h3 id="Find-alive-hosts-with-icmp-protocol"><a href="#Find-alive-hosts-with-icmp-protocol" class="headerlink" title="Find alive hosts with icmp protocol"></a>Find alive hosts with icmp protocol</h3><pre><code>// Find alive hosts with icmp protocol
// Win32 console project, compile with VS2005
// Create by Dennis
// 2013-04-09

// Reference:
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa366050%28v=vs.85%29.aspx

#include &lt;winsock2.h&gt;
#include &lt;iphlpapi.h&gt;
#include &lt;icmpapi.h&gt;
#include &lt;process.h&gt;
#include &lt;stdio.h&gt;

#pragma comment(lib, &quot;iphlpapi.lib&quot;)
#pragma comment(lib, &quot;ws2_32.lib&quot;)

#define IP_SECTION &quot;192.168.110.%d&quot;

CRITICAL_SECTION cs;
int g_ip_index = 0;

unsigned int __stdcall IcmpThread(LPVOID LPARAM)
{
    // Declare and initialize variables

    EnterCriticalSection(&amp;cs);
    char ip[16] = {0};
    sprintf(ip, IP_SECTION, ++g_ip_index);
    HANDLE hIcmpFile;
    unsigned long ipaddr = INADDR_NONE;
    DWORD dwRetVal = 0;
    char SendData[32] = &quot;Data Buffer&quot;;
    LPVOID ReplyBuffer = NULL;
    DWORD ReplySize = 0;

    ipaddr = inet_addr(ip);
    if (ipaddr == INADDR_NONE) {
        return 1;
    }

    hIcmpFile = IcmpCreateFile();
    if (hIcmpFile == INVALID_HANDLE_VALUE) {
        printf(&quot;\tUnable to open handle.\n&quot;);
        printf(&quot;IcmpCreatefile returned error: %ld\n&quot;, GetLastError() );
        return 1;
    }    

    ReplySize = sizeof(ICMP_ECHO_REPLY) + sizeof(SendData);
    ReplyBuffer = (VOID*) malloc(ReplySize);
    if (ReplyBuffer == NULL) {
        printf(&quot;\tUnable to allocate memory\n&quot;);
        return 1;
    }    
    LeaveCriticalSection(&amp;cs);

    dwRetVal = IcmpSendEcho(hIcmpFile, ipaddr, SendData, sizeof(SendData), 
        NULL, ReplyBuffer, ReplySize, 10);
#if 0
    if (dwRetVal != 0) {
        PICMP_ECHO_REPLY pEchoReply = (PICMP_ECHO_REPLY)ReplyBuffer;
        struct in_addr ReplyAddr;
        ReplyAddr.S_un.S_addr = pEchoReply-&gt;Address;
        printf(&quot;\tSent icmp message to %s\n&quot;, ip);
        if (dwRetVal &gt; 1) {
            printf(&quot;\tReceived %ld icmp message responses\n&quot;, dwRetVal);
            printf(&quot;\tInformation from the first response:\n&quot;); 
        }    
        else {    
            printf(&quot;\tReceived %ld icmp message response\n&quot;, dwRetVal);
            printf(&quot;\tInformation from this response:\n&quot;); 
        }    
        printf(&quot;\t  Received from %s\n&quot;, inet_ntoa( ReplyAddr ) );
        printf(&quot;\t  Status = %ld\n&quot;, 
            pEchoReply-&gt;Status);
        printf(&quot;\t  Roundtrip time = %ld milliseconds\n&quot;, 
            pEchoReply-&gt;RoundTripTime);
    }
    else {
        printf(&quot;\tCall to IcmpSendEcho failed.\n&quot;);
        printf(&quot;\tIcmpSendEcho returned error: %ld\n&quot;, GetLastError() );
        return 1;
    }
#else
    if (dwRetVal != 0)
        printf(&quot;%16s is alive\n&quot;, ip);
#endif
}

int __cdecl main(int argc, char **argv)  {

    InitializeCriticalSection(&amp;cs);

    int netsize = 255;

    HANDLE *phThread = (HANDLE*)malloc(netsize*sizeof(HANDLE));
    for (int i=1; i&lt;netsize; i++)
    {
        // _beginthreadex if more effect than CreateThread
        // you can google it for more information
        phThread[i-1] = (HANDLE)_beginthreadex(NULL, 0, IcmpThread, 0, 0, NULL);
    }

    // There is a limit count for function WaitForMultipleObjects
    int netcount = netsize-1;
    int waitcount = 0;
    for (int i=0; i&lt;netcount;)
    {
        waitcount = MAXIMUM_WAIT_OBJECTS;
        if (netcount-i&lt;MAXIMUM_WAIT_OBJECTS)
            waitcount = netcount;
        WaitForMultipleObjects(waitcount,&amp;(phThread[i]),TRUE,INFINITE);
        i += waitcount;
    }

    free(phThread);

    DeleteCriticalSection(&amp;cs);
    system(&quot;pause&quot;);
    return 0;
}    
</code></pre><p><strong>Output as below:</strong>  </p>
<pre><code>  192.168.110.1 is alive
  192.168.110.5 is alive
  192.168.110.6 is alive
 192.168.110.30 is alive
 192.168.110.32 is alive
 192.168.110.35 is alive
 ...
192.168.110.248 is alive
192.168.110.249 is alive
Press any key to continue. . .
</code></pre><h3 id="IPFind"><a href="#IPFind" class="headerlink" title="IPFind"></a>IPFind</h3><p>I have write a windows application with MFC, you can find the source code and execute file here <a href="https://github.com/matrix207/VC/blob/master/IPFind" target="_blank" rel="external">IPFind</a><br><img src="/assets/image/posts/IPFind.PNG" alt="IPFind"></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/04/09/find-alive-hosts/" data-id="ciqqpe1j1004enmpv4u3rion7" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/network/">network</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-kvm" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/04/07/kvm/" class="article-date">
  <time datetime="2013-04-06T16:00:00.000Z" itemprop="datePublished">2013-04-07</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/tools/">tools</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/04/07/kvm/">kvm</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>##KVM Install</p>
<h4 id="Install-Tools"><a href="#Install-Tools" class="headerlink" title="Install Tools:"></a>Install Tools:</h4><p><code>yum -y install kvm python-virtinst libvirt  bridge-utils virt-manager qemu-kvm-tools  virt-viewer  virt-v2v</code></p>
<h4 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h4><pre><code>virt-install --name=win2003test --ram 1024 --vcpus=1 --disk path=/mnt/win2003test.img,size=20 --accelerate --cdrom /mnt/WindowsServer2003SP2.iso --graphics vnc,password=123456,listen=0.0.0.0,port=5920 --force --autostart
</code></pre><h4 id="删除"><a href="#删除" class="headerlink" title="删除"></a>删除</h4><pre><code>[root@localhost ~]# virsh -c qemu:///system
virsh # list --all
virsh # destroy win2003Test
virsh # undefine win2003Test
</code></pre><h4 id="安装过程中，在系统重启后，设置CD"><a href="#安装过程中，在系统重启后，设置CD" class="headerlink" title="安装过程中，在系统重启后，设置CD"></a>安装过程中，在系统重启后，设置CD</h4><pre><code>修改 /etc/libvirt/qemu/win2003test.xml 或执行命令 virsh edit win2003test
&lt;source dev=&apos;/mnt/WindowsServer2003SP2.iso&apos;/&gt; 
加入到
&lt;disk type=&apos;block&apos; device=&apos;cdrom&apos;&gt;
 &lt;driver name=&apos;qemu&apos; type=&apos;raw&apos;/&gt;
 &lt;source dev=&apos;/mnt/WindowsServer2003SP2.iso&apos;/&gt; 
 ...
&lt;/disk&gt;

然后执行一下命令  

[root@localhost ~]# virsh -c qemu:///system
virsh # shutdown win2003test
virsh # destroy win2003test
virsh # define /etc/libvirt/qemu/win2003test.xml
virsh # start win2003test
virsh # quit
[root@localhost ~]# virt-viewer win2003test
</code></pre><h4 id="解决出现两个鼠标光标问题"><a href="#解决出现两个鼠标光标问题" class="headerlink" title="解决出现两个鼠标光标问题"></a>解决出现两个鼠标光标问题</h4><pre><code>修改 /etc/libvirt/qemu/win2003test.xml 或执行命令 virsh edit win2003test 
&lt;/console&gt;
&lt;input type=&apos;tablet&apos; bus=&apos;usb&apos;/&gt;
&lt;input type=&apos;mouse&apos; bus=&apos;ps2&apos;/&gt;
</code></pre><h4 id="安装网卡驱动"><a href="#安装网卡驱动" class="headerlink" title="安装网卡驱动"></a>安装网卡驱动</h4><pre><code>下载virtio-win-0.1-52.iso
http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-0.1-52.iso
修改
&lt;source dev=&apos;/mnt/WindowsServer2003SP2.iso&apos;/&gt; 
为
&lt;source dev=&apos;/mnt/virtio-win-0.1-52.iso&apos;/&gt; 
重启系统
[root@localhost ~]# virsh shutdown win2003test
[root@localhost ~]# virsh define /etc/libvirt/qemu/win2003test.xml
[root@localhost ~]# virsh start win2003test
进入系统后就可以从光驱安装网卡驱动了.

[root@localhost ~]# /etc/init.d/network stop
Shutting down interface br0:  [  OK  ]
Shutting down interface eth0:  [  OK  ]
Shutting down interface eth1:  [  OK  ]
Shutting down interface eth2:  [  OK  ]
Shutting down interface eth3:  [  OK  ]
Shutting down interface eth4:  [  OK  ]
Shutting down interface eth5:  [  OK  ]
Shutting down loopback interface:  [  OK  ]
</code></pre><h4 id="参考文章"><a href="#参考文章" class="headerlink" title="参考文章:"></a>参考文章:</h4><ul>
<li><a href="http://blog.chinaunix.net/uid-796091-id-3291518.html" target="_blank" rel="external">fedora 17上kvm的配置</a></li>
<li><a href="http://g.51cto.com/netengineer/216414" target="_blank" rel="external">CentOS 6.3部署KVM虚拟机V1.0</a></li>
<li><a href="http://www.techotopia.com/index.php/Creating_an_RHEL_6_KVM_Networked_Bridge_Interface" target="_blank" rel="external">Creating an RHEL 6 KVM Networked Bridge Interface</a></li>
<li><a href="http://www.cnblogs.com/kumulinux/archive/2012/12/06/2808678.html" target="_blank" rel="external">RHEL6 KVM安装备忘</a></li>
<li><a href="http://www.linux-kvm.org/page/HOWTO" target="_blank" rel="external">KVM Howto</a></li>
</ul>
<hr>
<p>##KVM Bridge</p>
<p>command list:  </p>
<pre><code>[root@localhost ~]#service network stop
[root@localhost ~]#cd /etc/sysconfig/network-scripts/
[root@localhost ~]#cat ifcfg-eth0
    DEVICE=eth0
    ONBOOT=yes
    BRIDGE=br0
    HWADDR=b3:1c:51:ca:a9:f0

[root@localhost ~]#cat ifcfg-br0
    DEVICE=br0   
    TYPE=Bridge 
    BOOTPROTO=static
    ONBOOT=yes 
    IPADDR=192.168.110.30
    NETMASK=255.255.255.192
    GATEWAY=192.168.110.1

[root@localhost ~]#service network start

[root@localhost ~]#route add default gw 192.168.110.1 dev br0
</code></pre><h4 id="参考"><a href="#参考" class="headerlink" title="参考:"></a>参考:</h4><ul>
<li><a href="http://bloodiron888.blog.163.com/blog/static/1647332712010101853023528/" target="_blank" rel="external">linux kvm 网卡Bridge设置</a></li>
<li><a href="http://blog.csdn.net/samlei/article/details/7598541" target="_blank" rel="external">Redhat/CentOS6.2 x86系统KVM虚拟机网络配置(二)—Bridge方式</a></li>
<li><a href="http://bbs.chinaunix.net/thread-3591185-1-1.html" target="_blank" rel="external">CentOS 6.0 下 KVM 网卡桥接的配置</a></li>
<li><a href="http://forum.ubuntu.org.cn/viewtopic.php?t=154792" target="_blank" rel="external">虚拟化方案之－－kvm简单教程（网络桥接方案，全文更新中。。。）</a></li>
<li><a href="www.anyshare.org/open/355.html">RHEL KVM虚拟机网桥设置</a></li>
<li><a href="http://linuxkvm.blogspot.co.uk/2012/01/linux-bridge.html" target="_blank" rel="external">Linux 原生橋接器（Bridge）</a></li>
<li><a href="http://www.net527.cn/a/Ciscomoniqi/Ciscomoniqiruanjian/2012/0524/23095.html" target="_blank" rel="external">Fedora KVM Networking</a></li>
<li><a href="http://www.07net01.com/linux/Redhat_CentOS6_2_x86xitongKVMxunijiwangluopeizhi_Bridgefangshi_23477_1352279007.html" target="_blank" rel="external">Redhat/CentOS6.2 x86系统KVM虚拟机网络配置 Bridge方式</a></li>
</ul>
<hr>
<p>##KVM Bond</p>
<h4 id="关掉NetworkManager服务"><a href="#关掉NetworkManager服务" class="headerlink" title="关掉NetworkManager服务"></a>关掉NetworkManager服务</h4><pre><code>[root@localhost ~]# service NetworkManager stop

[root@localhost ~]# service NetworkManager status
NetworkManager is stopped
</code></pre><h4 id="列出当前的网卡的个数"><a href="#列出当前的网卡的个数" class="headerlink" title="列出当前的网卡的个数"></a>列出当前的网卡的个数</h4><pre><code>查询eth*,其中[[:digit:]]匹配数字，+匹配用来一个或多个数字
[root@localhost ~]# ip a | grep -E &quot;eth[[:digit:]]+:&quot;
2: eth4: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
3: eth2: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000
4: eth5: &lt;BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
5: eth3: &lt;BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
6: eth6: &lt;BROADCAST,MULTICAST&gt; mtu 1500 qdisc noop state DOWN qlen 1000
7: eth7: &lt;BROADCAST,MULTICAST&gt; mtu 1500 qdisc noop state DOWN qlen 1000    
[root@localhost ~]# ip a | grep -E &quot;eth[[:digit:]]+:&quot; | wc -l
6

[root@localhost ~]# grep -E &quot;eth[[:digit:]]+&quot; /proc/net/dev | awk -F&apos; |:&apos; &apos;{print $3}&apos; | sort
eth2
eth3
eth4
eth5
eth6
eth7

HowTo: Linux Show List Of Network Cards    
http://www.cyberciti.biz/faq/linux-list-network-cards-command/
</code></pre><h4 id="列出bond的个数和组成"><a href="#列出bond的个数和组成" class="headerlink" title="列出bond的个数和组成"></a>列出bond的个数和组成</h4><pre><code>[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0 
DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
USERCTL=no
TYPE=Ethernet
BRIDGE=br1

查看绑定状态
[root@localhost ~]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: adaptive load balancing
Primary Slave: None
Currently Active Slave: eth5    # 当前使用eth5
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth3           # 绑定成员eth3
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:24:ec:20:00:fe
Slave queue ID: 0

Slave Interface: eth5           # 绑定成员eth5
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:24:ec:20:00:fd
Slave queue ID: 0
</code></pre><h4 id="列出网桥的个数及其组成，和vnet的情况"><a href="#列出网桥的个数及其组成，和vnet的情况" class="headerlink" title="列出网桥的个数及其组成，和vnet的情况"></a>列出网桥的个数及其组成，和vnet的情况</h4><pre><code>1).查询网桥个数
    [root@localhost ~]# brctl show
    bridge name    bridge id        STP enabled    interfaces
    br0        8000.0024ec2000fb    no        eth4
                                tap0
    br1        8000.0024ec2000fe    no        bond0
                                tap1
                                vnet0
    virbr0        8000.525400d2af63    yes        virbr0-nic

    [root@localhost ~]# ifconfig | grep -E &quot;^br[[:digit:]]&quot;
    br0       Link encap:Ethernet  HWaddr 00:24:EC:20:00:FB  
    br1       Link encap:Ethernet  HWaddr 00:24:EC:20:00:FE  
    [root@localhost ~]# ifconfig | grep -E &quot;^br[[:digit:]]&quot; | wc -l
    2

2).查询vnet情况,使用sed，查找vnet开始到空行结束的行
    [root@localhost ~]# ifconfig | sed -n &apos;/vnet[[:digit:]]/,/^$/p&apos;
    vnet0     Link encap:Ethernet  HWaddr FE:24:EC:20:00:FF  
              inet6 addr: fe80::fc24:ecff:fe20:ff/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:2669288 errors:0 dropped:0 overruns:0 frame:0
              TX packets:26731021 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:500 
              RX bytes:323410384 (308.4 MiB)  TX bytes:2495782478 (2.3 GiB)

    [root@localhost ~]# 
</code></pre><h4 id="两个网卡建立绑定"><a href="#两个网卡建立绑定" class="headerlink" title="两个网卡建立绑定"></a>两个网卡建立绑定</h4><pre><code>[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0 
DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
USERCTL=no
TYPE=Ethernet
BRIDGE=br1

echo &quot;MASTER=bond0
SLAVE=yes&quot; &gt;&gt; /etc/sysconfig/network-scripts/ifcfg-eth0

echo &quot;MASTER=bond0
SLAVE=yes&quot; &gt;&gt; /etc/sysconfig/network-scripts/ifcfg-eth1
</code></pre><h4 id="一个绑定建立一个网桥"><a href="#一个绑定建立一个网桥" class="headerlink" title="一个绑定建立一个网桥"></a>一个绑定建立一个网桥</h4><pre><code>[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=&quot;br0&quot;
BOOTPROTO=static
NM_CONTROLLED=&quot;yes&quot;
ONBOOT=yes
IPADDR=192.168.110.30
PREFIX=24
GATEWAY=192.168.110.1
DEFROUTE=yes
TYPE=Bridge
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-br1
DEVICE=&quot;br1&quot;
BOOTPROTO=none
NM_CONTROLLED=&quot;yes&quot;
ONBOOT=yes
IPADDR=192.168.110.32
NETMASK=255.255.255.0
GATEWAY=192.168.110.1
DEFROUTE=yes
TYPE=Bridge
</code></pre><h4 id="删除网桥，删除绑定"><a href="#删除网桥，删除绑定" class="headerlink" title="删除网桥，删除绑定"></a>删除网桥，删除绑定</h4><pre><code>[root@localhost ~]# brctl delif br1 eth3
[root@localhost ~]# brctl delif br1 eth5
[root@localhost ~]# brctl delbr br1

service network stop
rm -f ifcfg-br*
</code></pre><h4 id="A-bonded-machine-look-as-below"><a href="#A-bonded-machine-look-as-below" class="headerlink" title="A bonded machine look as below:"></a>A bonded machine look as below:</h4><pre><code>[root@localhost ~]# ls  /etc/sysconfig/network-scripts/
ifcfg-bond0  ifcfg-eth3  ifdown-bnep  ifdown-post    ifup          ifup-ipv6   ifup-ppp       init.ipv6-global
ifcfg-br0    ifcfg-eth4  ifdown-eth   ifdown-ppp     ifup-aliases  ifup-isdn   ifup-routes    net.hotplug
ifcfg-br1    ifcfg-eth5  ifdown-ippp  ifdown-routes  ifup-bnep     ifup-plip   ifup-sit       network-functions
ifcfg-eth0   ifcfg-lo    ifdown-ipv6  ifdown-sit     ifup-eth      ifup-plusb  ifup-tunnel    network-functions-ipv6
ifcfg-eth1   ifdown      ifdown-isdn  ifdown-tunnel  ifup-ippp     ifup-post   ifup-wireless
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0 
DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
USERCTL=no
TYPE=Ethernet
BRIDGE=br1
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-br1
DEVICE=&quot;br1&quot;
BOOTPROTO=none
NM_CONTROLLED=&quot;yes&quot;
ONBOOT=yes
IPADDR=192.168.110.32
NETMASK=255.255.255.0
GATEWAY=192.168.110.1
DEFROUTE=yes
TYPE=Bridge
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth3
DEVICE=eth3
BOOTPROTO=static
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
TYPE=Ethernet
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth5
DEVICE=eth5
BOOTPROTO=static
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
TYPE=Ethernet
[root@localhost ~]# cat /etc/modprobe.d/modprobe.conf 
alias bond0 bonding
options bond0 miimon=100 mode=6
[root@localhost ~]# grep -r &quot;bond0&quot; /etc
/etc/modprobe.d/modprobe.conf:alias bond0 bonding
/etc/modprobe.d/modprobe.conf:options bond0 miimon=100 mode=6
/etc/sysconfig/network-scripts/ifcfg-eth5:MASTER=bond0
/etc/sysconfig/network-scripts/ifcfg-bond0:DEVICE=bond0
/etc/sysconfig/network-scripts/ifcfg-eth3:MASTER=bond0
[root@localhost ~]#
</code></pre><h4 id="参考-1"><a href="#参考-1" class="headerlink" title="参考:"></a>参考:</h4><ul>
<li><a href="www.cnblogs.com/kumulinux/archive/2012/10/18/2808702.html">RHEL6双网卡绑定</a></li>
<li><a href="http://join12.blog.51cto.com/1194785/992705" target="_blank" rel="external">linux系统双网卡绑定详细配置</a></li>
<li><a href="http://19861022.blog.51cto.com/353339/556781" target="_blank" rel="external">CentOS5.5 双网卡绑定</a></li>
<li><a href="http://bbs.ywlm.net/thread-1156-1-1.html" target="_blank" rel="external">Linux双网卡绑定实现负载均衡(Bonding双网卡绑定)</a></li>
<li><a href="www.yunvn.com/thread-2464-1-1.html">shell脚本自动配置双网卡绑定</a></li>
<li><a href="http://serverfault.com/questions/316623/what-is-the-correct-way-to-setup-a-bonded-bridge-on-centos-6-for-kvm-guests" target="_blank" rel="external">What is the correct way to setup a bonded bridge on Centos 6 for KVM guests?</a></li>
</ul>
<hr>
<h4 id="Other"><a href="#Other" class="headerlink" title="Other:"></a>Other:</h4><ul>
<li><a href="http://wiki.ubuntu.org.cn/Kvm%E6%95%99%E7%A8%8B#KVM_.E4.B8.8E_vbox.E7.9A.84.E5.8C.BA.E5.88.AB" target="_blank" rel="external">Kvm教程</a></li>
<li><a href="http://trac.nchc.org.tw/grid/wiki/KVM/OpenNebula" target="_blank" rel="external">KVM + OpenNebula = Virtual Cluster Deployment★★★★</a></li>
<li><a href="http://www.ibm.com/developerworks/cn/linux/l-using-kvm/" target="_blank" rel="external">使用 KVM 虚拟化技术</a></li>
<li><a href="http://www.csdn.net/article/a/2013-09-12/15816609-Virtualization" target="_blank" rel="external">虚拟化发展简史和京东的虚拟化应用方案</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/04/07/kvm/" data-id="ciqqpe1iw0048nmpv3cvw7b88" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/virtual/">virtual</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-arp-on-windows" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/04/07/arp-on-windows/" class="article-date">
  <time datetime="2013-04-06T16:00:00.000Z" itemprop="datePublished">2013-04-07</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/windows/">windows</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/04/07/arp-on-windows/">arp on windows</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>Reference:</p>
<ul>
<li><a href="http://blog.csdn.net/fishbaoyu/article/details/5982816" target="_blank" rel="external">使用WinPcap分析ARP包获得局域网内的IP地址</a></li>
<li><a href="http://blog.163.com/cxmapleleave@126/blog/static/9735695200946103926699/" target="_blank" rel="external">winpcap一些开发实践</a></li>
<li><a href="http://badishi.com/arp-poisoning-with-winpcap/" target="_blank" rel="external">ARP-Poisoning With WinPcap</a></li>
<li><a href="http://blog.csdn.net/wegatron/article/details/7636929" target="_blank" rel="external">winpcap发送arp包</a></li>
<li><a href="http://www.codeproject.com/articles/6579/spoofing-the-arp-table-of-remote-computers-on-a-la" target="_blank" rel="external">Spoofing the ARP Table of Remote Computers on a LAN</a></li>
<li><a href="http://www.cnblogs.com/Mr_JinRui/archive/2010/07/15/1778211.html" target="_blank" rel="external">详谈调用winpcap驱动写arp多功能工具</a></li>
<li><a href="http://hi.baidu.com/lewvan/item/2b707bea1a5332c3baf37dea" target="_blank" rel="external">抓取ARP包，ARP包结构解析</a></li>
<li><a href="http://www.winpcap.org/" target="_blank" rel="external">winpcap</a></li>
<li><a href="http://zh.wikipedia.org/zh-cn/ARP" target="_blank" rel="external">地址解析协议</a></li>
<li><a href="http://zh.wikipedia.org/wiki/ARP%E6%AC%BA%E9%A8%99" target="_blank" rel="external">ARP欺騙-ARP spoofing</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/04/07/arp-on-windows/" data-id="ciqqpe1iu0045nmpv29tf7bv6" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/network/">network</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-convert-mysql-to-sqlite" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/04/02/convert-mysql-to-sqlite/" class="article-date">
  <time datetime="2013-04-01T16:00:00.000Z" itemprop="datePublished">2013-04-02</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/database/">database</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/04/02/convert-mysql-to-sqlite/">convert mysql to sqlite</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="安装-mysql"><a href="#安装-mysql" class="headerlink" title="安装 mysql"></a>安装 mysql</h3><pre><code>yum install mysql
</code></pre><h3 id="安装-sqlite"><a href="#安装-sqlite" class="headerlink" title="安装 sqlite"></a>安装 sqlite</h3><pre><code>yum install sqlite-devel
</code></pre><h3 id="MySql常用命令"><a href="#MySql常用命令" class="headerlink" title="MySql常用命令"></a>MySql常用命令</h3><pre><code>登陆数据库
[root@localhost ~] mysql -uroot -p123456 mysql

显示已有数据库
mysql&gt; show databases;

进入数据库
mysql&gt; use mytest;

数据库中的表
mysql&gt; show tables;
</code></pre><h3 id="脚本实现-mysql-转为-sqlite"><a href="#脚本实现-mysql-转为-sqlite" class="headerlink" title="脚本实现: mysql 转为 sqlite"></a>脚本实现: mysql 转为 sqlite</h3><p><a href="https://gist.github.com/esperlu/943776/" target="_blank" rel="external">mysql2sqlite.sh</a></p>
<h3 id="终端操作记录"><a href="#终端操作记录" class="headerlink" title="终端操作记录"></a>终端操作记录</h3><pre><code># 上传脚本
[root@localhost sqlite]# sshpass -p 1234 scp mysql2sqlite.sh 192.168.1.103:/root
[root@localhost sqlite]# ssh 172.16.50.117
[root@localhost ~]# ls
mysql2sqlite.sh

# 执行转换mysql数据库到sqlite数据库,转换后的文件为database.sqlite
[root@localhost ~]# ./mysql2sqlite.sh -u root -p123456 mysql | sqlite3 database.sqlite
memory
[root@localhost ~]# ls -lh
total 632K
-rw-r--r-- 1 root root 629K 2013-04-02 09:08 database.sqlite
-rwxr-xr-x 1 root root 3.0K 2013-04-02 08:49 mysql2sqlite.sh

# 打开数据库文件
[root@localhost ~]# sqlite3 database.sqlite  
SQLite version 3.6.17
Enter &quot;.help&quot; for instructions
Enter SQL statements terminated with a &quot;;&quot;
sqlite&gt; .database                   # 显示数据库
seq  name             file                                                      
---  ---------------  ----------------------------------------------------------
0    main             /root/database.sqlite                                     
sqlite&gt; .tables                     # 显示表格
columns_priv               proc                     
db                         procs_priv               
event                      servers                  
func                       tables_priv              
help_category              time_zone                
help_keyword               time_zone_leap_second    
help_relation              time_zone_name           
help_topic                 time_zone_transition     
host                       time_zone_transition_type
ndb_binlog_index           user                     
plugin                   
sqlite&gt; select * from user;         # 查询表格信息
....                                # 此处省略输出
sqlite&gt; .exit                       # 退出
[root@localhost ~]#

# 导出其他数据库mytest, 这里出现了错误,待解决.
[root@localhost ~]# ./mysql2sqlite.sh -u root -p123456 mytest | sqlite3 mytest.sqlite
memory
SQL error near line 746: near &quot;COMMENT&quot;: syntax error
SQL error near line 808: no such table: main.user_log
SQL error near line 809: no such table: main.user_log
[root@localhost ~]# ls
</code></pre><p>reference:</p>
<ul>
<li><a href="https://gist.github.com/esperlu/943776/" target="_blank" rel="external">mysql2sqlite.sh</a></li>
<li><a href="http://my.oschina.net/chunquedong/blog/25913" target="_blank" rel="external">MySQL命令</a></li>
<li><a href="http://my.oschina.net/ncu033/blog/103540" target="_blank" rel="external">MYSQL命令大全</a></li>
<li><a href="http://stackoverflow.com/questions/5164033/export-a-mysql-database-to-sqlite-database" target="_blank" rel="external">Export a MySQL Database to SQLite Database</a></li>
<li><a href="http://www.sqlite.org/cvstrac/wiki?p=ConverterTools" target="_blank" rel="external">sqlite - Converter Tools</a></li>
<li><a href="www.cnblogs.com/lwm-1988/archive/2011/08/20/2147573.html">sqlite3 命令行操作</a></li>
<li><a href="www.cnblogs.com/zeroone/archive/2010/05/11/1732834.html">mysqldump备份还原</a> </li>
<li><a href="http://www.jbip.net/content/how-convert-mysql-sqlite" target="_blank" rel="external">How-to: Convert mysql to sqlite</a></li>
<li><a href="http://blog.sina.com.cn/s/blog_a9ec688101019m8i.html" target="_blank" rel="external">mysql to sqlite database</a></li>
<li><a href="http://radicallyrails.blogspot.com/2011/05/how-to-install-sqlite3-on-fedora.html" target="_blank" rel="external">How to install SQLite3 on Fedora</a></li>
<li><a href="https://github.com/athlite/sqlite3-to-mysql/blob/master/sqlite3-to-mysql" target="_blank" rel="external">sqlite3-to-mysql</a></li>
<li><a href="www.stat.berkeley.edu/~statcur/Workshop2/Assignments/Baseball/instructions.html">Shell scripts for converting MySQL dump into SQLite</a></li>
<li><a href="http://mifunny.info/convert-mysql-to-sqlite-script-330.html" target="_blank" rel="external">MySQL转SQLite Shell脚本</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/04/02/convert-mysql-to-sqlite/" data-id="ciqqpe1is0042nmpv2hi6xiwp" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/database/">database</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-use-raid" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/03/31/use-raid/" class="article-date">
  <time datetime="2013-03-30T16:00:00.000Z" itemprop="datePublished">2013-03-31</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/storage/">storage</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/03/31/use-raid/">use raid</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="Linux下建立raid1"><a href="#Linux下建立raid1" class="headerlink" title="Linux下建立raid1"></a>Linux下建立raid1</h3><pre><code>1、先用fdisk在硬盘上划分出空间。
    fdisk /dev/sdc  (后面的根据自己实际情况修改，因为我这里是虚拟机，
    所以就用2个500M的来做成一个raid)
    然后将其的功能改为 Linux raid autodetect 
    (也就是在fdisk下面 用t选择功能然后输入 --&gt;fd)

2、建立raid
    mdadm -C /dev/md1 -l 1 -n 2 /dev/sda /dev/sdb
    下面是在分区上建raid
    mdadm -C /dev/md1 -l 1 -n 2 /dev/sda -n 2 /dev/sda1 /dev/sda2
    mdadm -C raid阵列所在 -l raid等级 -n 设备数 设备分别是什么
    建立完毕之后，可以通过cat /proc/mdstat 查看是否成功

3、格式化
    mkfs.ext3 /dev/md1

4、挂载
    mount /dev/md1 /raid1

5、建立mdadm.conf文件
    echo &apos;DEVICE /dev/sd[ab]&apos; &gt; /etc/mdadm.conf
    mdadm -Ds &gt;&gt; /etc/mdadm.conf

6. view raid
    mdadm -D /dev/md1
    cat /proc/mdstat
    mdadm -E /dev/sda
    mdadm -E /dev/sdb

7. 配置mdadm开机自启动 
    设备配置文件只能使系统在开机时正常启用RAID设备，但自动挂载RAID设备还是要再修改/etc/fstab
    #vi /etc/fstab
    ===============================================
    /dev/md0 /mnt/raid ext3 defaults 0 0
    ===============================================

8. 停止与开启RAID设备：
    停止：
    #umount /mnt/raid
    #mdadm -S /dev/md0
    mdadm: stopped /dev/md0
    开启：
    使用配置文件时：
    #mdadm -As /dev/md0
    mdadm: /dev/md0 has been started with 3 drives and 1 spare.
    没有使用配置文件时：
    #mdadm -A /dev/md0 /dev/sd[bcde]
    mdadm: /dev/md0 has been started with 3 drives and 1 spare.

9. 故障演示
    1).将一个磁盘标记为faulty，模拟硬盘坏损
    #mdadm /dev/md0 -f /dev/sdb
    2).查看RAID5重建过程
    #mdadm -D /dev/md0    
    #cat /proc/mdstat 
    3).查看完成坏损设备后的RAID状态
    #mdadm -D /dev/md0
    #cat /proc/mdstat 
    4).移除坏损设备
    #mdadm /dev/md0 -r /dev/sdb
    mdadm: hot removed /dev/sdb
    5).添加新的设备
    #mdadm /dev/md0 -a /dev/sdb
    mdadm: added /dev/sdb
    6).查看最终状态
    #mdadm -D /dev/md0
    #cat /proc/mdstat 

10. 删除整个RAID：
    mdadm /dev/md0 --fail /dev/sda --remove /dev/sda
    mdadm /dev/md0 --fail /dev/sdb --remove /dev/sdb
    mdadm --stop /dev/md0
    mdadm --misc --zero-superblock /dev/sda
    mdadm --misc --zero-superblock /dev/sdb
    即： 先删除RAID中的所有设备，然后停止该RAID即可
</code></pre><h3 id="mdadm语法"><a href="#mdadm语法" class="headerlink" title="mdadm语法"></a>mdadm语法</h3><pre><code>基本语法 ： mdadm [mode] [options]
[mode] 有7种：
    Assemble：将以前定义的某个阵列加入当前在用阵列。
    Build：   Build a legacy array ，每个device 没有 superblocks
    Create：  创建一个新的阵列，每个device 具有 superblocks
    Manage： 管理阵列，比如 add 或 remove
    Misc：   允许单独对阵列中的某个 device 做操作，比如抹去superblocks 或 终止在用的阵列。
    Follow or Monitor:监控 raid 1,4,5,6 和 multipath 的状态
    Grow：   改变raid 容量或 阵列中的 device 数目
可用的 [options]:
-A, --assemble：加入一个以前定义的阵列
-B, --build：Build a legacy array without superblocks.
-C, --create：创建一个新的阵列
-Q, --query：查看一个device，判断它为一个 md device 或是 一个 md 阵列的一部分
-D, --detail：打印一个或多个 md device 的详细信息
-E, --examine：打印 device 上的 md superblock 的内容
-F, --follow, --monitor：选择 Monitor 模式
-G, --grow：改变在用阵列的大小或形态
-h, --help：帮助信息，用在以上选项后，则显示该选项信息
--help-options
-V, --version
-v, --verbose：显示细节
-b, --brief：较少的细节。用于 --detail 和 --examine 选项
-f, --force
-c, --config= ：指定配置文件，缺省为 /etc/mdadm/mdadm.conf
-s, --scan：扫描配置文件或 /proc/mdstat以搜寻丢失的信息。配置文件/etc/mdadm/mdadm.conf
create 或 build 使用的选项:
-c, --chunk=:Specify chunk size of kibibytes. 缺省为 64.
--rounding=: Specify rounding factor for linear array (==chunk size)
-l, --level=:设定 raid level.
--create可用:linear, raid0, 0, stripe, raid1,1, mirror, raid4, 4, raid5, 5, raid6, 6, multipath, mp.
--build可用：linear, raid0, 0, stripe.
-p, --parity=：设定 raid5 的奇偶校验规则:eft-asymmetric, left-symmetric, right-asymmetric, right-symmetric, la, ra, ls, rs.缺省为left-symmetric
--layout=:类似于--parity
-n, --raid-devices=:指定阵列中可用 device 数目，这个数目只能由 --grow 修改
-x, --spare-devices=：指定初始阵列的富余device 数目
-z, --size=：组建RAID1/4/5/6后从每个device获取的空间总数
--assume-clean:目前仅用于 --build 选项
-R, --run:阵列中的某一部分出现在其他阵列或文件系统中时，mdadm会确认该阵列。此选项将不作确认。
-f, --force:通常mdadm不允许只用一个device 创建阵列，而且创建raid5时会使用一个device作为missing drive。此选项正相反。
-a, --auto{=no,yes,md,mdp,part,p}{NN}：
</code></pre><h3 id="other"><a href="#other" class="headerlink" title="other:"></a>other:</h3><pre><code>1). check file system type
    before check, should mount the device first
    [root@localhost ]# df -T /mnt/raid1/
    Filesystem    Type   1K-blocks      Used Available Use% Mounted on
    /dev/md0      ext3   961433496    204572 912390856   1% /mnt/raid1
    [root@localhost ]# mount
    ubi0 on / type ubifs (rw)
    proc on /proc type proc (rw)
    sysfs on /sys type sysfs (rw)
    devpts on /dev/pts type devpts (rw,gid=5,mode=620)
    none on /var/tmp type tmpfs (rw)
    /dev/md0 on /mnt/raid1 type ext3 (rw)
    [root@localhost ]# df -T
    Filesystem    Type   1K-blocks      Used Available Use% Mounted on
    ubi0         ubifs      201464    191516      9948  96% /
    none         tmpfs       62136         0     62136   0% /var/tmp
    /dev/md0      ext3   961433496    204572 912390856   1% /mnt/raid1

    reference:
    (1). Linux how to determine the file system type
        www.cyberciti.biz/faq/linux-how-to-determine-find-out-file-system-type/ 
2).如果想了解你的kernel目前支持哪些文件系统，可以查看/proc/filesystems的内容 
    reference:
    (1).linux /etc/fstab 文件说明 www.wokeke.com/?p=350 
</code></pre><h3 id="Reference"><a href="#Reference" class="headerlink" title="Reference:"></a>Reference:</h3><ul>
<li><a href="http://linux.vbird.org/linux_basic/0420quota.php#raid" target="_blank" rel="external">鳥哥的 Linux 私房菜 軟體磁碟陣列 (Software RAID)</a></li>
<li><a href="http://page.renren.com/600235506/note/486081565?op=pre&amp;curTime=1282876355000" target="_blank" rel="external">Linux建立Raid</a></li>
<li><a href="http://blog.csdn.net/sense5/article/details/3888249" target="_blank" rel="external">mdadm详解</a></li>
<li><a href="http://supportex.net/2010/11/determine-raid-controller-type-model/" target="_blank" rel="external">How to determine RAID controller type and a model</a></li>
<li><a href="www.cyberciti.biz/faq/linux-how-to-delete-a-partition-with-fdisk-command/">Linux: How to delete a partition with fdisk command</a></li>
<li><a href="www.51chongdian.net/bbs/thread-35739-1-1.html">Linux DD命令删除掉分区shell</a></li>
<li><a href="blog.csdn.net/fjb2080/article/details/5032274">使用libparted库写个程序来打印我们的设备信息</a></li>
<li><a href="yuetao.org/linux-fdisk/">linux fdisk 分区、格式化、挂载！</a></li>
<li><a href="www.ixpub.net/thread-763965-1-1.html">关于删除软raid设备md0</a></li>
<li><a href="http://david0341.iteye.com/blog/382399" target="_blank" rel="external">Linux软Raid配置</a></li>
<li><a href="http://blog.csdn.net/sense5/article/details/1828868" target="_blank" rel="external">mdadm使用详解及RAID 5简单分析</a></li>
</ul>
<h3 id="我的一些raid操作"><a href="#我的一些raid操作" class="headerlink" title="我的一些raid操作:"></a>我的一些raid操作:</h3><pre><code>1. stop raid
    mdadm -S /dev/md0
    mdadm -S /dev/md1
    mdadm -S /dev/md126
    mdadm -S /dev/md127
2. create raid 1
    mdadm -Cv -l1 -n2 /dev/sda /dev/sdb --assume-clean --home-host=raidtest
3. check states
    cat /proc/mdstat

系统中原来插有两块盘，分别显示为/dev/sda /dev/sdb
如果把第一块盘/dev/sda拔掉，重启后，第二块盘自动识别为/dev/sda
如果原来/dev/sda和/dev/sdb建了raid1，拔掉/dev/sda并重启系统后，做如下操作:
[root@localhost ]# cat /proc/mdstat 
Personalities : [linear] [raid0] [raid1] 
md0 : active raid1 sda[1]
      976761424 blocks super 1.2 [2/1] [_U]  # 正常应该是[UU]

unused devices: &lt;none&gt;
[root@localhost ]# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Fri Mar 29 06:48:49 2013
     Raid Level : raid1
     Array Size : 976761424 (931.51 GiB 1000.20 GB)
  Used Dev Size : 976761424 (931.51 GiB 1000.20 GB)
   Raid Devices : 2
  Total Devices : 1
    Persistence : Superblock is persistent

    Update Time : Fri Mar 29 07:17:39 2013
          State : clean, degraded
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
  Spare Devices : 0

           Name : mytestraid:0
           UUID : c76eab52:2e80d8e1:67772808:024ea0b6
         Events : 6

    Number   Major   Minor   RaidDevice State
       0       0        0        0      removed     # 这里看到有一块盘被移除了
       1       8        0        1      active sync   /dev/sda
[root@localhost ]# 


正常情况
[root@localhost ]# cat /proc/mdstat 
Personalities : [linear] [raid0] [raid1] 
md0 : active raid1 sdb[1] sda[0]
      976761424 blocks super 1.2 [2/2] [UU]

unused devices: &lt;none&gt;

拔掉一块raid盘，删掉剩下的raid盘数据，重启后插入有raid数据的盘
[root@localhost ]# cat /proc/mdstat 
Personalities : [linear] [raid0] [raid1] 
md127 : inactive sdb[0](S)
      976761560 blocks super 1.2
</code></pre>
      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/03/31/use-raid/" data-id="ciqqpe1iq003znmpvvlp6arjg" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/storage/">storage</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-connect-wifi-in-linux-terminal" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/03/13/connect-wifi-in-linux-terminal/" class="article-date">
  <time datetime="2013-03-12T16:00:00.000Z" itemprop="datePublished">2013-03-13</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/network/">network</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/03/13/connect-wifi-in-linux-terminal/">connect wifi in linux terminal</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>##1.工具介绍</p>
<h3 id="wireless-tools"><a href="#wireless-tools" class="headerlink" title="wireless-tools"></a>wireless-tools</h3><p>   使用到的工具 iwlist、iwconfig、dhclient<br>   只适用于WEP加密方式, WPA方式需要使用wpa_supplicant</p>
<h3 id="wpa-supplicant"><a href="#wpa-supplicant" class="headerlink" title="wpa_supplicant"></a>wpa_supplicant</h3><p>   可用于WPA加密方式</p>
<p>##2.编译源码</p>
<h3 id="wireless-tools-1"><a href="#wireless-tools-1" class="headerlink" title="wireless-tools"></a>wireless-tools</h3><p>   1). 下载 wireless_tools.29.tar.gz<br>     <code>wget http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/wireless_tools.29.tar.gz</code></p>
<p>   2). 编译、安装<br>        <code>tar xvf wireless_tools.29.tar.gz</code><br>        <code>cd wireless_tools.29</code><br>        <code>make</code><br>        <code>make install</code>  </p>
<h3 id="wpa-supplicant-1"><a href="#wpa-supplicant-1" class="headerlink" title="wpa_supplicant"></a>wpa_supplicant</h3><p>   1). 下载<br>     <code>wget http://www.openssl.org/source/openssl-0.9.8e.tar.gz</code><br>     <code>wget http://hostap.epitest.fi/releases/wpa_supplicant-2.0.tar.gz</code></p>
<p>   2). Reference:<br>     <a href="http://blog.csdn.net/penglijiang/article/details/8573946" target="_blank" rel="external">http://blog.csdn.net/penglijiang/article/details/8573946</a><br>     <a href="http://blog.csdn.net/ti_tantbx/article/details/7037741" target="_blank" rel="external">http://blog.csdn.net/ti_tantbx/article/details/7037741</a></p>
<p>##3.操作步骤</p>
<h3 id="wireless-tools-2"><a href="#wireless-tools-2" class="headerlink" title="wireless_tools"></a>wireless_tools</h3><p>注意： 操作前提，无线路由器使用WEP方式加密</p>
<p>使用步骤:  </p>
<ul>
<li>使用命令ifconfig查找无线网卡接口，通常为wlan0  </li>
<li>使用命令iwlist扫描无线网络  </li>
<li>使用命令iwconfig设置要连接的无线网络  </li>
<li>使用命令iwconfig设置无线网络密码  </li>
<li>使用命令dhclient开始连接网络  </li>
<li>使用命令ifconfig和ping验证是否无线网络设置成功  </li>
</ul>
<p>下面是使用TP-Link无线网卡连接无线路由器的操作记录</p>
<pre><code>[root@localhost ~]# ifconfig
[root@localhost ~]# iwlist wlan0 scanning
[root@localhost ~]# iwconfig wlan0 essid TP_Link_Test
[root@localhost ~]# iwconfig wlan0 key s:12349
[root@localhost ~]# dhclient wlan0
[root@localhost ~]# ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 14:CF:92:23:B5:BF  
          inet addr:192.168.1.101  Bcast:255.255.255.255  Mask:255.255.255.0
          inet6 addr: fe80::16cf:92ff:fe23:b5bf/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1141 errors:0 dropped:53252 overruns:0 frame:0
          TX packets:37 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:425292 (415.3 KiB)  TX bytes:6687 (6.5 KiB)

说明：
iwconfig wlan0 essid TP_Link_Test 这里的 TP_Link_Test 是无线网络名称
iwconfig wlan0 key s:12349 这里的s:表示密码为ASCII格式
</code></pre><h3 id="wpa-supplicant-2"><a href="#wpa-supplicant-2" class="headerlink" title="wpa_supplicant"></a>wpa_supplicant</h3><p>1). 生成配置文件<br>    其中TP_Link_Test为无线网络名称, 1234567890为无线网络密码<br>    <code>wpa_passphrase TP_Link_Test &quot;1234567890&quot; &gt; /etc/wpa_supplicant.conf</code></p>
<p>2). 修改配置/etc/wpa_supplicant/wpa_supplicant.conf  </p>
<pre><code>ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel

network={
    ssid=&quot;TP_Link_Test&quot;
    proto=WPA
    key_mgmt=WPA-PSK
    pairwise=TKIP
    group=TKIP
    #psk=&quot;1234567890&quot;
    psk=eed346e10ee03dd93b9d25abbc117d58be9f619cf7d6aa1c7f3c080bbe94b84e
}
</code></pre><p>3). 连接网络<br>    <code>wpa_supplicant -Dwext -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf</code></p>
<pre><code>执行命令后可能出现&quot;Operation not permitted&quot;,看似是错误信息，不用管。  
[root@localhost ~]# wpa_supplicant -Dwext -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf 
ioctl[SIOCSIWAP]: Operation not permitted
Trying to associate with 1c:92:73:b0:02:33 (SSID=&apos;TP_Link_Test&apos; freq=2412 MHz)
Associated with 1c:92:73:b0:02:33
WPA: Key negotiation completed with 1c:92:73:b0:02:33 [PTK=TKIP GTK=TKIP]
CTRL-EVENT-CONNECTED - Connection to 1c:92:73:b0:02:33 completed (auth) [id=0 id_str=]
WPA: Group rekeying completed with 1c:fa:68:b9:18:16 [GTK=TKIP]
</code></pre><p>4). 获取IP<br>    <code>dhclient wlan0</code>  </p>
<p>5). 检查是否获取成功<br>    <code>ifconfig wlan0</code><br>    ping 网关:<br>    <code>ping 192.168.1.1</code></p>
<p>6). 断开网络<br>    <code>wpa_cli disable_network 0</code><br>    <code>wpa_cli remove_network 0</code><br>    <code>dhclient -x wlan0</code>  </p>
<p>Reference:  </p>
<ul>
<li><a href="http://hostap.epitest.fi/wpa_supplicant/" target="_blank" rel="external">http://hostap.epitest.fi/wpa_supplicant/</a></li>
<li>[<a href="http://blog.163.com/wxiongn@126/blog/static/11788203820102262748358/" target="_blank" rel="external">http://blog.163.com/wxiongn@126/blog/static/11788203820102262748358/</a>] (<a href="http://blog.163.com/wxiongn@126/blog/static/11788203820102262748358/" target="_blank" rel="external">http://blog.163.com/wxiongn@126/blog/static/11788203820102262748358/</a>)</li>
<li>[<a href="http://xitong.iteye.com/blog/1723427" target="_blank" rel="external">http://xitong.iteye.com/blog/1723427</a>] (<a href="http://xitong.iteye.com/blog/1723427" target="_blank" rel="external">http://xitong.iteye.com/blog/1723427</a>)</li>
<li>[<a href="http://evan7s.blog.163.com/blog/static/108955356201132494921476/" target="_blank" rel="external">http://evan7s.blog.163.com/blog/static/108955356201132494921476/</a>] (<a href="http://evan7s.blog.163.com/blog/static/108955356201132494921476/" target="_blank" rel="external">http://evan7s.blog.163.com/blog/static/108955356201132494921476/</a>)</li>
<li>[<a href="http://blog.csdn.net/lin772662623/article/details/7830336" target="_blank" rel="external">http://blog.csdn.net/lin772662623/article/details/7830336</a>] (<a href="http://blog.csdn.net/lin772662623/article/details/7830336" target="_blank" rel="external">http://blog.csdn.net/lin772662623/article/details/7830336</a>)</li>
<li><a href="http://blog.csdn.net/ti_tantbx/article/details/7037741" target="_blank" rel="external">wpa_supplicant的移植和可能遇到的问题</a></li>
<li><a href="https://github.com/kimperator/Samen/blob/master/src/samen-handler/samen-handler.c" target="_blank" rel="external">https://github.com/kimperator/Samen/blob/master/src/samen-handler/samen-handler.c</a></li>
</ul>
<p>##4.其他参考资料  </p>
<ul>
<li><a href="http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html" target="_blank" rel="external">Wireless Tools for Linux</a></li>
<li><a href="http://blog.csdn.net/jacobywu/article/details/7366080" target="_blank" rel="external">http://blog.csdn.net/jacobywu/article/details/7366080</a></li>
<li><a href="https://help.ubuntu.com/community/WifiDocs/WiFiHowTo" target="_blank" rel="external">Wi-Fi WLAN wireless home networking information</a></li>
<li><a href="docs.fedoraproject.org/en-US/Fedora/13/html/Wireless_Guide/sect-Wireless_Guide-Fedora_And_Wireless-iwconfig.html">Fedora: Using the command line interface</a></li>
<li><a href="http://sourceforge.net/projects/getwifi/?source=dlp" target="_blank" rel="external">getwifi, a bash script</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/03/13/connect-wifi-in-linux-terminal/" data-id="ciqqpe1in003wnmpvux6tz6pa" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/network/">network</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-skype-api-for-linux" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/03/12/skype-api-for-linux/" class="article-date">
  <time datetime="2013-03-11T16:00:00.000Z" itemprop="datePublished">2013-03-12</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/linux/">linux</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/03/12/skype-api-for-linux/">skype api for linux</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>之前有开发过windows下的skype api应用, 并做成ActiveX控件形式。</p>
<p>现在基本上在Linux环境下工作，今天兴趣袭来，汇总下Linux下开发Skype客户端程序相关资料,</p>
<p>以备将来开发之需:</p>
<ul>
<li><a href="http://dev.skype.com/accessories" target="_blank" rel="external">Skype accessories</a></li>
<li><a href="http://dev.skype.com/desktop-api-reference#Linux" target="_blank" rel="external">Skype Desktop API Reference Manual</a></li>
<li><a href="http://www.baiyuxiong.com/?p=30" target="_blank" rel="external">ubuntu /linux下skype api开发环境搭建</a></li>
<li><a href="http://www.kabatology.com/02/05/ubuntu-how-to-send-text-messages-with-skype-for-linux/" target="_blank" rel="external">Ubuntu: How to send Text Messages with Skype for Linux</a></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/03/12/skype-api-for-linux/" data-id="ciqqpe1il003snmpvpvwekzme" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/api/">api</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/skype/">skype</a></li></ul>

    </footer>
  </div>
  
</article>


  
    <article id="post-install-skype-on-fedora18-x86_64" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2013/03/12/install-skype-on-fedora18-x86_64/" class="article-date">
  <time datetime="2013-03-11T16:00:00.000Z" itemprop="datePublished">2013-03-12</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/linux/">linux</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2013/03/12/install-skype-on-fedora18-x86_64/">install skype on fedora18 x86_64</a>
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <ol>
<li><p>保存以下脚本为 skype-on-fedora18.sh</p>
<pre><code>#!/bin/sh
################################################################################
# Install skype on fedora 18 x86_64
# Reference: http://www.if-not-true-then-false.com/2012/install-skype-on-fedora-centos-red-hat-rhel-scientific-linux-sl/ 
################################################################################

yum install -y alsa-lib.i686 fontconfig.i686 freetype.i686 glib2.i686 libSM.i686 libXScrnSaver.i686 libXi.i686 libXrandr.i686 libXrender.i686 libXv.i686 libstdc++.i686 pulseaudio-libs.i686 qt.i686 qt-x11.i686 zlib.i686

yum install -y qtwebkit.i686

cd /tmp

## Skype 4.1 Dynamic for Fedora ##
wget --trust-server-names http://www.skype.com/go/getskype-linux-dynamic

mkdir /opt/skype

## Extract Skype 4.1 on Fedora ##
tar xvf skype-4.1* -C /opt/skype --strip-components=1

ln -s /opt/skype/skype.desktop /usr/share/applications/skype.desktop
ln -s /opt/skype/icons/SkypeBlue_48x48.png /usr/share/icons/skype.png
ln -s /opt/skype/icons/SkypeBlue_48x48.png /usr/share/pixmaps/skype.png

touch /usr/bin/skype
chmod 755 /usr/bin/skype

cat &lt;&lt;EOF &gt;&gt; /usr/bin/skype
#!/bin/sh
export SKYPE_HOME=&quot;/opt/skype&quot;

\$SKYPE_HOME/skype --resources=\$SKYPE_HOME \$*
EOF
</code></pre></li>
<li><p>增加可执行权限 chmod +x skype-on-fedora18.sh</p>
</li>
<li><p>执行脚本 ./skype-on-fedora18.sh</p>
</li>
<li><p>安装完毕后运行 skype</p>
</li>
</ol>
<p>Reference :</p>
<p><a href="http://www.if-not-true-then-false.com/2012/install-skype-on-fedora-centos-red-hat-rhel-scientific-linux-sl/" target="_blank" rel="external">Install Skype 4.1/4.0 on Fedora 18/17, CentOS/RHEL/SL 6.3</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2013/03/12/install-skype-on-fedora18-x86_64/" data-id="ciqqpe1ig003pnmpvpt60r6hu" class="article-share-link">Partager</a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/skype/">skype</a></li></ul>

    </footer>
  </div>
  
</article>


  


  <nav id="page-nav">
    <a class="extend prev" rel="prev" href="/page/13/">&laquo; __('prev')</a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/12/">12</a><a class="page-number" href="/page/13/">13</a><span class="page-number current">14</span><a class="page-number" href="/page/15/">15</a><a class="page-number" href="/page/16/">16</a><span class="space">&hellip;</span><a class="page-number" href="/page/18/">18</a><a class="extend next" rel="next" href="/page/15/">__('next') &raquo;</a>
  </nav>
</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Catégories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/blog/">blog</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/database/">database</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/english/">english</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/kernel/">kernel</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/language/">language</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/linux/">linux</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/math/">math</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/network/">network</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/others/">others</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/person/">person</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/program/">program</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/source/">source</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/storage/">storage</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/tools/">tools</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/windows/">windows</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Mot-clés</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/FAQ/">FAQ</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/IRC/">IRC</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Translation/">Translation</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/android/">android</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/api/">api</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/assembly/">assembly</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/awk/">awk</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/batch/">batch</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/blog/">blog</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/book/">book</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/">c</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/">c++</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/cache/">cache</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/crash/">crash</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/database/">database</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/debug/">debug</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/dot/">dot</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/driver/">driver</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/emacs/">emacs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/exploit/">exploit</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/file-system/">file system</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/filesystem/">filesystem</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/flowchart/">flowchart</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/gcc/">gcc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/google/">google</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/graphviz/">graphviz</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hexo/">hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/hosts/">hosts</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/iscsi/">iscsi</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/">java</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/javascript/">javascript</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/job/">job</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/json/">json</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/kernel/">kernel</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/linux/">linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lisp/">lisp</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lua/">lua</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/makefile/">makefile</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/malloc/">malloc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/math/">math</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/maxima/">maxima</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memory/">memory</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/memory-overflow/">memory overflow</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/mtrace/">mtrace</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/netdisk/">netdisk</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/network/">network</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/others/">others</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/pandoc/">pandoc</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/performance/">performance</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/person/">person</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/protobuf/">protobuf</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/rsync/">rsync</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sed/">sed</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/shell/">shell</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/skype/">skype</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sms/">sms</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/source/">source</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/ssh/">ssh</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/stack/">stack</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/storage/">storage</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/study/">study</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/svn/">svn</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/sync/">sync</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/test/">test</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/time/">time</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/tools/">tools</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/valgrind/">valgrind</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vi/">vi</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vim/">vim</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/virtual/">virtual</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wget/">wget</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/windows/">windows</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/wireshark/">wireshark</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/write/">write</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/xml/">xml</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Nuage de mot-clés</h3>
    <div class="widget tagcloud">
      <a href="/tags/FAQ/" style="font-size: 10px;">FAQ</a> <a href="/tags/IRC/" style="font-size: 10px;">IRC</a> <a href="/tags/Translation/" style="font-size: 13px;">Translation</a> <a href="/tags/android/" style="font-size: 10px;">android</a> <a href="/tags/api/" style="font-size: 10px;">api</a> <a href="/tags/assembly/" style="font-size: 10px;">assembly</a> <a href="/tags/awk/" style="font-size: 11px;">awk</a> <a href="/tags/batch/" style="font-size: 14px;">batch</a> <a href="/tags/blog/" style="font-size: 10px;">blog</a> <a href="/tags/book/" style="font-size: 10px;">book</a> <a href="/tags/c/" style="font-size: 16px;">c</a> <a href="/tags/c/" style="font-size: 19px;">c++</a> <a href="/tags/cache/" style="font-size: 10px;">cache</a> <a href="/tags/crash/" style="font-size: 10px;">crash</a> <a href="/tags/database/" style="font-size: 17px;">database</a> <a href="/tags/debug/" style="font-size: 12px;">debug</a> <a href="/tags/dot/" style="font-size: 10px;">dot</a> <a href="/tags/driver/" style="font-size: 10px;">driver</a> <a href="/tags/emacs/" style="font-size: 11px;">emacs</a> <a href="/tags/exploit/" style="font-size: 10px;">exploit</a> <a href="/tags/file-system/" style="font-size: 10px;">file system</a> <a href="/tags/filesystem/" style="font-size: 12px;">filesystem</a> <a href="/tags/flowchart/" style="font-size: 10px;">flowchart</a> <a href="/tags/gcc/" style="font-size: 10px;">gcc</a> <a href="/tags/git/" style="font-size: 12px;">git</a> <a href="/tags/google/" style="font-size: 11px;">google</a> <a href="/tags/graphviz/" style="font-size: 11px;">graphviz</a> <a href="/tags/hexo/" style="font-size: 10px;">hexo</a> <a href="/tags/hosts/" style="font-size: 10px;">hosts</a> <a href="/tags/iscsi/" style="font-size: 14px;">iscsi</a> <a href="/tags/java/" style="font-size: 10px;">java</a> <a href="/tags/javascript/" style="font-size: 10px;">javascript</a> <a href="/tags/job/" style="font-size: 10px;">job</a> <a href="/tags/json/" style="font-size: 10px;">json</a> <a href="/tags/kernel/" style="font-size: 14px;">kernel</a> <a href="/tags/linux/" style="font-size: 14px;">linux</a> <a href="/tags/lisp/" style="font-size: 10px;">lisp</a> <a href="/tags/lua/" style="font-size: 10px;">lua</a> <a href="/tags/makefile/" style="font-size: 10px;">makefile</a> <a href="/tags/malloc/" style="font-size: 10px;">malloc</a> <a href="/tags/math/" style="font-size: 11px;">math</a> <a href="/tags/maxima/" style="font-size: 10px;">maxima</a> <a href="/tags/memory/" style="font-size: 11px;">memory</a> <a href="/tags/memory-overflow/" style="font-size: 10px;">memory overflow</a> <a href="/tags/mtrace/" style="font-size: 10px;">mtrace</a> <a href="/tags/netdisk/" style="font-size: 10px;">netdisk</a> <a href="/tags/network/" style="font-size: 20px;">network</a> <a href="/tags/others/" style="font-size: 18px;">others</a> <a href="/tags/pandoc/" style="font-size: 10px;">pandoc</a> <a href="/tags/performance/" style="font-size: 16px;">performance</a> <a href="/tags/person/" style="font-size: 11px;">person</a> <a href="/tags/protobuf/" style="font-size: 11px;">protobuf</a> <a href="/tags/python/" style="font-size: 10px;">python</a> <a href="/tags/rsync/" style="font-size: 10px;">rsync</a> <a href="/tags/sed/" style="font-size: 11px;">sed</a> <a href="/tags/shell/" style="font-size: 15px;">shell</a> <a href="/tags/skype/" style="font-size: 11px;">skype</a> <a href="/tags/sms/" style="font-size: 10px;">sms</a> <a href="/tags/source/" style="font-size: 11px;">source</a> <a href="/tags/ssh/" style="font-size: 10px;">ssh</a> <a href="/tags/stack/" style="font-size: 10px;">stack</a> <a href="/tags/storage/" style="font-size: 15px;">storage</a> <a href="/tags/study/" style="font-size: 10px;">study</a> <a href="/tags/svn/" style="font-size: 11px;">svn</a> <a href="/tags/sync/" style="font-size: 10px;">sync</a> <a href="/tags/test/" style="font-size: 11px;">test</a> <a href="/tags/time/" style="font-size: 10px;">time</a> <a href="/tags/tools/" style="font-size: 16px;">tools</a> <a href="/tags/valgrind/" style="font-size: 10px;">valgrind</a> <a href="/tags/vi/" style="font-size: 10px;">vi</a> <a href="/tags/vim/" style="font-size: 14px;">vim</a> <a href="/tags/virtual/" style="font-size: 11px;">virtual</a> <a href="/tags/wget/" style="font-size: 10px;">wget</a> <a href="/tags/windows/" style="font-size: 11px;">windows</a> <a href="/tags/wireshark/" style="font-size: 10px;">wireshark</a> <a href="/tags/write/" style="font-size: 13px;">write</a> <a href="/tags/xml/" style="font-size: 10px;">xml</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">July 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/04/">April 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/03/">March 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/02/">February 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">January 2016</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/11/">November 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/10/">October 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/09/">September 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/08/">August 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/07/">July 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/06/">June 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/03/">March 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/02/">February 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/01/">January 2015</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/12/">December 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/11/">November 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/09/">September 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/08/">August 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/07/">July 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/06/">June 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/05/">May 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/04/">April 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2014/03/">March 2014</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/11/">November 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/10/">October 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/09/">September 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/08/">August 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/07/">July 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/06/">June 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/05/">May 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/04/">April 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/03/">March 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/02/">February 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2013/01/">January 2013</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/12/">December 2012</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2012/09/">September 2012</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Articles récents</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2016/07/17/how-to-implement-malloc/">如何实现一个malloc</a>
          </li>
        
          <li>
            <a href="/2016/07/17/study-grep-more/">grep工作原理</a>
          </li>
        
          <li>
            <a href="/2016/07/17/2016-04-13-malloc/">malloc</a>
          </li>
        
          <li>
            <a href="/2016/04/27/include-what-you-use/">使用IWYU整理头文件引用</a>
          </li>
        
          <li>
            <a href="/2016/04/24/understand-gcc-assembly-output/">understand gcc assembly output</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2016 Matrix207<br>
      Propulsé by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>

  </div>
</body>
</html>